The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
I'm trying to redirect some old URLs to new ones in my .htaccess file using 301 redirects.
If the old URL ends in a file extension or a trailing slash:
RewriteBase /
RewriteRule ^old_page.html$ new_page.php [R=301,L]
RewriteRule ^old_page/$ new_page.php [R=301,L]
The redirects work as expected, i.e.:
www.mysite.com/old_page.html redirects in browser to www.mysite.com/new_page.php
www.mysite.com/old_page/ also redirects in browser to www.mysite.com/new_page.php
However, if the old URL does not end in a file extension or forward slash, the redirects do not work:
RewriteRule ^old_page/$ new_page.php [R=301,L]
www.mysite.com/old_page in browser returns 404 not found
On examining the rewrite error logs, it seems that the server is throwing a "filedoesnotexist error" for "old_page" before it even attempts to perform the redirect.
I've done similar things with other web hosts, and never encountered this problem before. I'm on shared VIP hosting - could it be due to a setting in the server's httpd.conf file, possibly with Allowoverride All|None|... or similar?
Cheers
Joel
I'm trying to redirect some old URLs to new ones in my .htaccess file using 301 redirects.
If the old URL ends in a file extension or a trailing slash:
RewriteBase /
RewriteRule ^old_page.html$ new_page.php [R=301,L]
RewriteRule ^old_page/$ new_page.php [R=301,L]
The redirects work as expected, i.e.:
www.mysite.com/old_page.html redirects in browser to www.mysite.com/new_page.php
www.mysite.com/old_page/ also redirects in browser to www.mysite.com/new_page.php
However, if the old URL does not end in a file extension or forward slash, the redirects do not work:
RewriteRule ^old_page/$ new_page.php [R=301,L]
www.mysite.com/old_page in browser returns 404 not found
On examining the rewrite error logs, it seems that the server is throwing a "filedoesnotexist error" for "old_page" before it even attempts to perform the redirect.
I've done similar things with other web hosts, and never encountered this problem before. I'm on shared VIP hosting - could it be due to a setting in the server's httpd.conf file, possibly with Allowoverride All|None|... or similar?
Cheers
Joel
There are probably different ways to fix this - but here's my simple method!
Surely the old location has actually got a file type?
i.e. My URL www.hmmm.ip3.co.uk/camera/ can also be found by typing
www.hmmm.ip3.co.uk/camera/index.php - obviously you may have to change the file type to htm/html/shtml or whatever you are using.
[s]Hmmm...[/s]
However, if the old URL does not end in a file extension or forward slash, the redirects do not work:
RewriteRule ^old_page/$ new_page.php [R=301,L]
www.mysite.com/old_page in browser returns 404 not found
Some clarification needed I think. That rule isnt going to match that URL so a 404 is expected if the old page doesnt exist anymore?
Do you really mean that rewrite rule should match to www.mysite.com/old_page or have you just copy/pasted it wrongly?
RewriteEngine on
RewriteBase /
RewriteRule ^old_page.html$ new_page.php [R=301,L]
RewriteRule ^old_page/?$ new_page.php [R=301,L]
The '?' just makes the trailing slash optional.