Forum Moderators: phranque
No, a parser was exactly what I needed.
I have some old but well ranked .htm pages which should be rewritten using php.
Insted of renaming them all to .php I wanted the names to remain the same.
This did the trick:
RemoveHandler .htm
AddType application/x-httpd-php .php .htm
...but it depends on server settings, some won't allow this, reason unknown.
In this way I made only .htm files to be parsed to php, .html remained intact.
Be aware that if your site gets a lot of traffic, and a good portion of the pages are .htm files, this can place considerable load on the webserver. Your solution requires the PHP engine to parse through .htm files unnecessarily (in some cases), where the Rewrite solution does not. Just food for thought.
Chad
Yes. I am aware of eventual extra load on server. That's why I made parsing for .htm files only.
My old files are all .htm so in the future I will make all php files with .htm extension, while regular HTML files will keep .html extension and will be not parsed to the PHP processing.
One site has a lot of rewrite rules. When I add this one from above the system goes seemingly into a loop.
What could be wrong here?:
######################################################
IndexIgnore .htaccess */.?* *~ *# */HEADER* */README* */_vti*
RewriteEngine on
#www to root
RewriteCond %{HTTP_HOST} ^www\.mysite\.com
RewriteRule ^(.*)$ [mysite.com...] [R=301,L]
#404 handling
ErrorDocument 404 [mysite.com...]
#pdf>htm
RewriteRule ^([^.]+)\.pdf$ [mysite.com...] [R=301,L]
#html>php
RewriteRule ([^.]+)\.html /$1.php [L]
The comment says #pdf>htm, but in fact, you are rewriting pdf->html
If the comment is wrong, then you'll need a more-advanced code method; See [webmasterworld.com...] msg#6
Jim
Accidentaly, I forgot to make file1.php which should be called with file1.htm and 404 was triggered.
This is in 404red.html:
######################################################
<HTML>
<head>
<meta HTTP-EQUIV="Refresh" CONTENT="3; URL=http://mysite.com/" target="_blank">
</head>
<body><H3>We are sorry, blah blah blah</h3>
</body>
</HTML>
#####################################################
Oh boy, should I change default index extension?
RewriteCond %{REQUEST_URI} !^/403\.html$
RewriteCond %{REQUEST_URI} !^/404red\.html$
RewriteCond %{REQUEST_URI} !^/410red\.html$
RewriteRule ^([^.]+)\.html /$1.php [L]
Jim