Search code examples
apachemod-rewriteurl-rewritingapache-config

Apache Url Rewrite- Linux


My site is build using PHP. So all files are .php extension. I need to change the extension to .html I got this code to do so.

RewriteEngine on

RewriteRule ^(.*).html$ $1.php [L]

I an able to access the files using .html.

But the problem now I am facing is

All menu links in the pages are hardcoded with hyperlink somefile.php.So all the requests are comming to server with .php extension and so the browser shows .php extension. So I tried to redirect the .php to .html, but it resulted in looping...

ie in menu when i click services the hyperlink for services are www.mydomain.com/services.php so the url in address bar is www.mydomain.com/services.php

I need to change it to .html

How??

Thanks in advance........


Solution

  • I'm not an expert on regex or apache so I might be wrong but it looks like that code is backwards to me. Try:

    RewriteRule ^(.*).php$ $1.html