Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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>
share|improve this question

marked as duplicate by GregD, voretaq7 Nov 11 '12 at 1:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2  
-1 for sounding like a whiny kid --> "pls help,". Server Fault 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 Answers 2

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
share|improve this answer

Use this rewriterule

RewriteRule ^(.*)\.html$ $1.php [L]
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.