Forum Moderators: phranque
I am now switching to a dynamic index.php page and need advice on how to do this.
Should I do a 301 re-direct from the .htm to .php?
I tried that with the following .HTACCESS file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
redirect 301 /directory/index.htm http://www.example.com/directory/index.php
This does not redirect the .htm file to the .php file. Any suggestions?
If you redirect, *every* page on your site will be considered new. Even if you are only changing the extention.
I highly recommend you serve the php information to the htm extention, like this:
RewriteCond %{HTTP_HOST} ^example.com
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
RewriteRule ([^.]+)\.htm$ /$1.php [L]
If you need to, you could also use a query_string containing the page name, and pass it to the php file, so you get the correct information.
EG user requests /yourpage.htm
You could give them the information from /index.php?page=yourpage
Again, if at all possible, do not make any changes to the URLs
Hope this helps.
Justin