Page 1 of 1
Redirect Problem
Posted: Fri Aug 12, 2011 3:11 pm
by BrendanM1990
I am having problems redirecting my old pages to my new server
i moved to wordpress and there pages don't have exstensions, they show like this
http://newsite.com/about
while my old server was
http://oldsite.com/about.html
Now i have tried php redirects and htaccess to point to the new address but get a not found error, is there away around this?
Re: Redirect Problem
Posted: Fri Aug 12, 2011 5:13 pm
by twinedev
Something similar to this must go BEFORE the wordpress code in .htaccess (else it takes over for the request and gives 404):
Code: Select all
RewriteRule ^containment\.html$ "http\:\/\/www\.domain\.com\/containment\/" [R=301,L]
RewriteRule ^downloads/$ "http\:\/\/www\.domain\.com\/category\/forms\/" [R=301,L]
RewriteRule ^downloads/K%209%20Information%20form\.doc$ "http\:\/\/www\.domain\.com\/media\/info\-form_2010.pdf" [R=301,L]
RewriteRule ^index\.htm$ "http\:\/\/www\.domain\.com\/index\.php" [R=301,L]
RewriteRule ^rescue\-rangers\.html$ "http\:\/\/www\.domain\.com\/videos\/" [R=301,L]
RewriteRule ^training\.html$ "http\:\/\/www\.domain\.com\/behavior\-modification\-temperment\-testing\/" [R=301,L]
This was taken directly from a site I maintain running WP, (well other than changing the domain). A thing to note, I went ahead and tried out cPanel to add these in automatically for me, but it put them AFTER the WP lines, so I had to manually move them up above it. If you used cPanel to add them in after WP is installed, probably the issue is they need moved to top of the file.
-Greg
Re: Redirect Problem
Posted: Fri Aug 12, 2011 11:02 pm
by BrendanM1990
will that put .html at the end of the pages?
Re: Redirect Problem
Posted: Fri Aug 12, 2011 11:35 pm
by twinedev
No, that will say if someone browses to (the first one for example)
http://www.domain.com/containment.html, the server will actually redirect the visitor to the new location of that content,
http://www.domain.com/containment
If you are WANTING it so they enter .html at the end (ie, reverse of what mine is doing), it can be done, I'd have to test this to make sure it would work, but would try this (again, before the ones for WP):
Code: Select all
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} .*\.html$
RewriteRule ^(.*)\.html$ $1 [L]
Main thing need to test and play with is that last line, may need to do
/$1 instead of just
$1, forget offhand if the leading slash is there already or not. Again, this is just off the top of my head, and I don't do this often enough I don't trust it without testing and/or looking it up.
-Greg
PS. also not that WP will produce links WITHOUT .html, and search engines MAY consider this as having pages with duplicate content.
Re: Redirect Problem
Posted: Sat Aug 13, 2011 10:38 am
by BrendanM1990
Ok well im not bothered about the html at the end as long as my old site with the .html pages redirects to the new wordpress site which hasnt got the exstensions, do i put the htacess code on the new wordpress site or the old site?
Re: Redirect Problem
Posted: Sat Aug 13, 2011 2:00 pm
by twinedev
The old site.
If there is already an .htaccess file there, add them to the beginning. Remember to escape certain characters (like in the example given above)
Re: Redirect Problem
Posted: Sat Aug 13, 2011 3:16 pm
by BrendanM1990
I tried one page just to test it but still getting the same result
here is the htaccess of the old site.
Code: Select all
AddType video/ogg .ogg
AddType video/mp4 .mp4
LoadModule rewrite_module modules/mod_rewrite.so
RewriteEngine ON
RewriteRule ^charlotte-gutter-protection\.html$ "http\:\/\/www\.greenenergync\.org\/charlotte-gutter-protection\/" [R=301]
http://www.greenenergync.org is the old site that does have the extensions like so
http://www.greenenergync.org/charlotte- ... ction.html
The new website is
http://www.lnihome.com
When typing in the first address(old one) it should take me to
http://www.lnihome.com/charlotte-gutter-protection/
I appriciate your help.
Re: Redirect Problem
Posted: Sat Aug 13, 2011 5:09 pm
by twinedev
You have the rewrite rule to take them right back to the old website, should have something like:
Code: Select all
RewriteRule ^charlotte-gutter-protection\.html$ "http\:\/\/www\.lnihome\.com\/charlotte-gutter-protection\/" [R=301,L]
Re: Redirect Problem
Posted: Sat Aug 13, 2011 5:13 pm
by BrendanM1990
Oh i see
That rule still takes me to
http://www.lnihome.com/charlotte-gutter-protection.html
which is a 404 rather than taking off the .html for a /
Re: Redirect Problem
Posted: Sat Aug 13, 2011 7:36 pm
by twinedev
There is something else going on, that command tells the browser to go to
http://www.lnihome.com/charlotte-gutter-protection so where you are ending up at a version with .html on the end, I'm not sure without actually looking at it. Can you post the full .htaccess file from the old server?
Here is the direct reply from the webserver from accessing the URL on old server:[text]HTTP/1.1 301 Moved Permanently
Date: Sun, 14 Aug 2011 00:16:44 GMT
Server: Microsoft-IIS/6.0
X-Powered-By: ASP.NET
X-AspNet-Version: 2.0.50727
Location:
http://www.lnihome.com/charlotte-gutter-protection.html
Cache-Control: private
Content-Length: 0[/text]
So it is something on the older server taking you to the .html version, not something on the new server.
Actually, one thing I didn't think to ask before was if it was even running Apache, which from this result, nope. I'm not familiar at all with IIS's redirects and how they work, let alone if it can really even process an .htaccess file.
As a side note, when I actually tried to browse to the old URL (to get the above header info), something tripped my antivirus software to block accessing the page redirected to.
Re: Redirect Problem
Posted: Sat Aug 13, 2011 8:00 pm
by BrendanM1990
That is the full htaccess file from the old server
Re: Redirect Problem
Posted: Sat Aug 13, 2011 8:15 pm
by twinedev
From here, unless someone else can help, need to check with the hosting provider to find out the correct way to do redirects on IIS, sorry I don't know it well enough to advise more.
-Greg