Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Before asking question let me tell you some assumptions here there are 5 files on my webserver index.php config.php read.php write.php .htaccess

I've wrote following URL rewriting rule in .htaccess

RewriteEngine on RewriteRule ^(\w+)$ read.php?id=$1

Now when I type it fetch data from read.php?id=xyz thats nice :)

But when I type it fetch data from index.php or when i type or or it fetch data from write.php , config.php and read.php respectively

I want data to be fectched from read.php?id=index or read.php?id=config or read.php?id=read or read.php?id=write

Any one can help me regarding this ?

Sorry for my poor english

share|improve this question
Options -multiviews

For some reason, your original rule must have a RewriteCond that checks to see if the file exists. Since multiviews is on, and index.php does exist and you've requested index, mod_negotiation will assume you want to get index.php

Your rule will work fine with multiviews off.

share|improve this answer

Try This.....

RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)/$ read.php?id=$1

share|improve this answer
Thanks for Reply, its still having same problem :( – Kunal Gautam Feb 7 '10 at 4:28
please check your other code. Just tested, It works for me fine! Note that the code I posted above requires a "/" at end of URL. You can remove it by removing the extra "/" before the "$" sign above. – Ankit Duseja Feb 9 '10 at 17:25

Use RewriteRule ^(.*)$ read.php?id=$1 [QSA,L] This way, all requests are rewritten

share|improve this answer
This is causing Internal Server Error – Kunal Gautam Feb 7 '10 at 5:53
Could you post your complete modrewrite section which causes the internal server error ? – Dominik Feb 7 '10 at 18:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.