Forum Moderators: phranque
I started with about 5 pages with 301's (renamed pages like pinkelephant.shtml to pink_elephant.shtml) and the 404. I then changed some more pages and added them as 301's. These are NOT working, if I try the old page name in the url, it just brings up the 404 page. All 5 of the old 301's still work fine though. The code is exactly the same for every redirect I really can't understand it. When I header check the new 301's, they are returned as 302 Found, and bring up the 404 page. Here is the code:
redirect 301 blue.shtml [blahblah.co.uk...]
ErrorDocument 404 [blahblah.co.uk...]
I have also removed my .htaccess file completley from my server, but the server header check still tells me that my origional redirects are still working and the newer ones are still going to the 404 page.
How can this be when I have removed the htaccess file?!
Could it be that because the first 5 I tried to redirect automatically picked up the new pages names because the only difference in the page name was an underscore?
I really need to list my full htaccess file to explain it better. The first 5 files I renamed and put a redirect on, changed from being
lightboxes.shtml to light_boxes.shtml (these work and the server header checker shows them as a 301)
and the newer redirects was changed from being
katana.shtml to katana_light_box.shtml (these don't work and the header checker shows it as a 302 Found, and sends back the 404 page)
- would the length of the newer files names have anything to do with it?
Also, this IS an apache server I'm on before anyone asks :P
RewriteRule (.*)display(.*)\.shtml /$1_display$2\.shtml [R=301]
RewriteRule (.*)stand(.*)\.shtml /$1_stand$2\.shtml [R=301]
this should handle singular and plural names.
Make sure you flush your browser cache (Temporary Internet Files) after each and every change to any code that does URL rewriting or redirects. Otherwise, your browser will very often get a cached page from your local machine, ISP, or network cache, and it will contain the headers it was originally delivered with.
Jim
try a simple rewrite first
RewriteRule retaildisplay.shtml /retail_display.shtml [R=301]
then build in wild cards after you get this working
there are some apache gurus here who could probably achieve what you want with a few lines and get it right first time. inexperienced guys like me need to experiment!
First test, request http://yourdomain.com/testpage.shtml?test1
Second test, request http://yourdomain.com/testpage.shtml?test2
etc.
The fake query string usually won't interfere with serving the page, but it will force the request to be passed through all caches to your server.
I should also note that if you update your pages frequently, you should take control of caching issues, and set up your server to provide correct Expires, max-age, and Last-Modified headers.
Jim
although I still don't know why some of my redirects already work with
redirect 301 blue.shtml [mydomain.com...]
RewriteEngine On
Options +FollowSymlinks
RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain\.co.uk
RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 [R=permanent]
RewriteCond %{REQUEST_FILENAME}!-f
RewriteRule ^blue\.shtml$ http://www.mydomain.co.uk/blue_tiny_widgets.shtml$1 [R=permanent]
RewriteRule ^green\.shtml$ http://www.mydomain.co.uk/green_tiny_widgets.shtml$1 [R=permanent]
RewriteRule ^tinywidgets\.shtml$ http://www.mydomain.co.uk/tiny_widgets.shtml$1 [R=permanent]
ErrorDocument 404 /404error.shtml