bugzbrian2
Member
Posted 1 year ago #
Hello,
I am trying to do a 301 redirect in .htaccess for my wordpress sitemap.xml. My blog is located in a separate folder (directory) within my primary domain. Any suggestions on what changes to make in my wordpress .htaccess file to do a redirect for url's. I am primarily concerned with doing a redirect for http:// reynoldspest.com/ reynoldsblog/sitemap.xml to http:// http://www.reynoldspest.com/ reynoldsblog/sitemap.xml. This is what my current .htaccess file looks like:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /reynoldsblog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /reynoldsblog/index.php [L]
</IfModule>
# END WordPress
You want to redirect NON www to http://WWW.yoursite?
For everything or JUST the sitemap?
bugzbrian2
Member
Posted 1 year ago #
I am only having trouble with some (not all) non "WWW" in my blog converting to "WWW" i.e. http://reynoldspest.com/reynoldsblog/sitemap.xml. I have been unsuccessful in my attempts to redirect this url and some others.
I am sure there is code for .htaccess to help me, but I do not know what to do.
Thanks
Yeah I get that. What I'm asking is if you want ALL of your http://reynoldspest.com/ URLs to look like http://www.reynoldspest.com/ or http://reynoldspest.com/ :)
Because I have an answer, and it's different depending on YOUR answer. So. All the URLs should have www or ONLY the sitemap.xml?
bugzbrian2
Member
Posted 1 year ago #
Yes, they all should be WWW
Thank you
That's easiest of all! :)
Put this code in your .htaccess ABOVE your WordPress section:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.reynoldspest.com$
RewriteRule ^(.*)$ http://www.reynoldspest.com/$1 [R=301]
bugzbrian2
Member
Posted 1 year ago #
I have that code in my other .htaccess in the root directory for my main site. I tried putting it in my reynoldsblog .htaccess but it does not work. :-(
Do you have your URLs within wordPress set to use www?
bugzbrian2
Member
Posted 1 year ago #
Yes-I changed them about a week ago and they all redirect except the http://reynoldspest.com/reynoldsblog/sitemap.xml. I also tried to implement some 301's for some navigation pages that I deleted, and was unable.
Yes-I changed them about a week ago and they all redirect except the http://reynoldspest.com/reynoldsblog/sitemap.xml
That's a plugin, right? Turn it off and back on.
I also tried to implement some 301's for some navigation pages that I deleted, and was unable.
Okay NOW it sounds like your .htaccess isn't being read correctly. Ask your host for some help on it. Tell them, specifically, that .htaccess isn't being processed.
bugzbrian2
Member
Posted 1 year ago #
I will call them and see what is going on. I'll let you know.
bugzbrian2
Member
Posted 1 year ago #
I spoke with HostGator and after about an hour of waiting for a solution and explaining about what was happening, I was finally told that since I notified Google about where my sitemap was now located that I would be okay and that there was no more that I could do. In a nutshell,these changes including the navigation pages that I deleted cannot be redirected.
Thanks for your help though,
BugzBrian