Forum Moderators: phranque
i have a website, and my client need to convert the .php extension into html. Give me the exact url_rewrite or masking mode which i can use and incorporate with .hta file.
Please help me!and if we convert the file into .html suppose if i have a query string how i will write my code.
Please help me
Basically, the search engines had indexed .htm files and I wanted to auto-redirect to my new php files.
You can see from the comments that the code was originally used to go from htm to phtml - I just changed the extension to php and it works correctly.
NOTE: If you're using this for your whole site (multi-directory), then you'll need to put this in an .htaccess file in each directory. That's what I had to do to get it to work. Unless, of course, one of the masters of Apache here can help you with that...
RewriteEngine on
RewriteBase /
# parse out basename, but remember the fact
RewriteRule ^(.*)\.htm$ $1 [C,E=WasHTM:yes]
# rewrite to document.phtml if exists
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [S=1]
If that is not what you want (it sounds like it, from your question), please explain more in detail as to your problem and how you'd like to see it fixed.
It is also missing at least one rule at the end, since [S=1] means to skip the next rule. If that rule is not present, and the requested .htm file does not exist as a .php file, then unpredicatable results will occur.
What's missing is something like:
RewriteCond %{ENV:WasHTM} ^yes$
RewriteRule ^(.*)$ $1.htm [L]
"If requested filename.htm ezists as filename.php, then serve filename.php, else attempt to serve requested filename.htm, and use default 404 error handler if it is missing."
I believe this code was taken from the Apache URL Rewriting Guide [httpd.apache.org], so refer to that document for an authoritative code sample.
Jim
But we will try to help you learn how. Start here [webmasterworld.com].
Jim