Forum Moderators: phranque

Message Too Old, No Replies

Rewrite url from php to html?

         

Aamit

9:58 am on Mar 31, 2009 (gmt 0)

10+ Year Member



root folder name :- demo
In demo folder there are 3 folders :- contact ,services ,about

I want to rewrite url:

[xyz.com...]
To->
[xyz.com...]

[xyz.com...]
To ->
[xyz.com...]

Where to put .htaccess file in root folder(in demo)
or in subfolders(contact ,services ,about )

I am writing below code in htaccess file

RewriteEngine on
RewriteBase /
RewriteRule ^(.*)\.html$ $1.php [L]

How to get correct solution?

g1smd

10:08 am on Mar 31, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you insist on using a rewrite, then put it in the root, and let it cater for all folder levels in the backreference. That is quite simple to do using
(([^/]*/)*[^.]+\.html)
or similar. You'll also need to link to the new URLs from the links on your pages, and you'll need to make sure that requests for the old URLs are sent a redirect to the new URL.

However, there was a much simpler way to do this. You could have used AddHandler to make URLs ending in .html be parsed for PHP scripts. That would have meant you carried on using the same URLs as before. As viewed from the web, nothing would have appeared to have changed.