Possibly one of the most basic rewrite questions there is.... I'm embarrassed I don't know how to do it My site has urls like: www.domain.com/page.php I'd like to change them to: www.domain.com/page/ and have it work with AND without trailing slash. How is it done?
Options +FollowSymLinks +Indexes RewriteEngine on RewriteBase / RewriteRule ^([^.]+)/$ $1.php [L] RewriteRule ^([^.]+)$ $1.php [L]
You da King! Thanks EDIT: Actually... there's a bit of a problem. I've tried to 301 the old php urls that Google has indexed, but I'm getting an error from Firefox "Firefox has detected that the server is redirecting the request for this address in a way that will never complete." I can see why it's doing this, but I don't know how to fix it. Options +FollowSymLinks RewriteEngine On RewriteCond %{HTTP_HOST} ^domain.com$ [OR] RewriteCond %{HTTP_HOST} www.domain.com$ [OR] RewriteCond %{HTTP_HOST} ^domain.com.au$ RewriteRule ^(.*)$ http://www.domain.com.au/$1 [R=301,L] RewriteRule ^([^.]+)/$ $1.php [L] RewriteRule ^([^.]+)$ $1.php [L] Redirect 301 /page1.php http://www.domain.com.au/page1/ Code (markup):
Can anyone help with the 301s? At the moment Google will see the 'new' domain.com/page1/ url as duplicate content of domain.com/page1.php. I need to 301 the indexed php pages to domain.com/page1/ etc There's only about 10 pages I need to 301, so I can enter them manually - if I knew how to do it. Anyone?
It's making apache go bonkers. No, it's domain.com/page1/. No it's not, it's domain.com/page1.php. No it's not.... That's why mod_rewrite should be done before search engines get them, and so you don't have old URLs indexed.