Hi, I am looking for some htaccess lines, this is what I want to do: www.domain.com/page1.shtml it would usually 404 because I only have page1.php. The extensions don't match.. The obvious answer is 301 redirect page1.shtml to page1.php But the problem is I have over 18,000 pages that need to be done.. So I would like to add a line in htaccess that says: If no match, try replacing the extension with .php BEFORE 404-ing... I already have a 404 script that does this- it will forward people to the new php page- BUT it would be much better for search spiders if it redirected to a .PHP extension BEFORE it 404's/ Any help?
Hello floodrod, Does this do anything for you? http://kb.mediatemple.net/questions/242/How+do+I+redirect+my+site+using+a+.htaccess+file? If not that, then https://www.google.com/search?q=.ht...,cf.osb&fp=9ed5a11d60142bec&biw=1331&bih=1047
NO- No help there. And I know how to use google. If you want to give me a link to read- please verify the link addresses the issue I asked about. This is what I need: If file does not exist- change extension to .php and check for a match. If match=YES 301 to the .php page. If no php page exists either- only then 404 thanks!
Try this: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)\.php$ $1.html [nc] Code (markup):
The "$1" part will replaced whatever is on ^(.*)\ place, so for example something.php becomes something.html and the [nc] means no case sensitive, you can leave it out if you want.
Nono- the html part.. $1.html [nc] why is .html in there? I want ALL PAGES that are not found to try the .php extension before 404-ing. I don't want it to try any other extensions. Only php Thanks by the way!
Sorry about that, this should be what you want: RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)\.shtml$ $1.php [nc] Code (markup):
Ok thanks- that code almost works right. It does show the right .php page but the address bar still says .shtml. I was hoping the code would 301 redirect to the .php page and the address bar should show the correct URL. Possible?