-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
    -1 for sounding like a whiny kid --> "pls help,". [SF] is for Professional System Administrators (et al) only. Please see our [FAQ] for details. – Chris S Aug 17 '12 at 13:51
  • +1 for Chris S, -1 for the question, and if I could: **`-20`** for SMS-typing (which is a kind of "I don't want to make any effort") – Olivier Pons Aug 17 '12 at 13:56
  • this question is more for stackoverflawn thatn server fault i think... – Anarko_Bizounours Aug 17 '12 at 14:47

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
  • 77,337
  • 11
  • 120
  • 212
0

Use this rewriterule

RewriteRule ^(.*)\.html$ $1.php [L]
Frands Hansen
  • 4,617
  • 1
  • 16
  • 29