0

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 domain.com/xyz it fetch data from read.php?id=xyz thats nice :)

But when I type domain.com/index it fetch data from index.php or when i type domain.com/write or domain.com/config or domain.com/read 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

3 Answers 3

1
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.

0

Try This.....

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

1
  • 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, 2010 at 17:25
0

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

2
  • This is causing Internal Server Error
    – Kunal Gautam
    Feb 7, 2010 at 5:53
  • Could you post your complete modrewrite section which causes the internal server error ?
    – Dominik
    Feb 7, 2010 at 18:38

You must log in to answer this question.