My Problem: I want anything.html to be directed to page.php?nicename=anything The problem is that when I use this line of code: RewriteRule ^(.*).html$ page.php?nicename=$1 [L] It also screws up every html page on my site including my index.html and any other .html files in the other directories. How do I get it to work without affecting my index.html file or files in other directories? I know there must be some conditional rule I can apply, but I just don't know which one to use.
Chage it to a static looking extention that you don't use, like .shtml or .htm. .php would just kill it, making apache not know what to spit out...and .php isn't as search engine friendly.
That's kind of obvious... what I want is to have the same file extension for all of my pages. What? That's the whole idea, I am trying to make my page.php?nicename=page into something like "page.html"
Add a condition that checks if the file exists - then only rewrite if the requested .html file is not a real .html page: RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^(.*).html$ page.php?nicename=$1 [L] Code (markup):
Wow thanks that helped a lot! The only problem now is that it is still affecting an index file in another directory because it isn't "real" Is there a conditional that will only apply the rule in my "/" base directory?
I think this will do the trick: RewriteCond %{SCRIPT_FILENAME} !-f RewriteRule ^([^/]*).html$ page.php?nicename=$1 [L] Code (markup):
If you want to understand how mod_rewrite works, here is a little light reading: http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html http://en.wikipedia.org/wiki/Regular_expression#Syntax