-3

Possible Duplicate:
Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

I have a dynamic website, so all the pages are in .php, but I want to show an address ending in .html on address bar, such as: my_domain_name/*.html.

I do I make a rewrite rule such that, if someone hits any url ending with .php (like my_domain/*.php) it will redirect to an address ending in .html?

htacess file:

 <IfModule mod_rewrite.c>
 Options +FollowSymLinks
 RewriteEngine on
  RewriteRule index-main.html index-main.php
 </IfModule>

2 Answers2

1

You'll need a couple rewrite rules to do that:

#Redirects if a request for a php files comes in.
RewriteCond %{REQUEST_URI} .php$
RewriteRule ^(.*)\.php.?$ $1.html [R=301,L]

#Rewrites requests for html files to find the php file on disk.
RewriteRule ^(.*)\.html$ $1.php
Chris S
  • 78,185
0

Use this rewriterule

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