Simple Mod-Rewrite rule - single rule - file exists
I have a very simple mod rewrite rule
Options FollowSymLinks
RewriteEngine On
RewriteRule ^hosted/essws/([^/]*)/$ /hosted/essws/?key=$1 [L]
I would like this rewrite to activate even if the file or directory exists.
For example: The URL:
http://localhost/hosted/es开发者_开发问答sws/candy-sweets-buffet/
Will load:
http://localhost/hosted/essws/index.php?key=candy-sweets-buffet
Even though the directory /hosted/essws/candy-sweets-buffet/ exists.
Any help would be much appreciated.
Options FollowSymLinks
RewriteEngine On
RewriteRule ^hosted/essws/([^/]*)/$ /hosted/essws/?key=$1 [L]
Look! rewriteRule doesn't care if directory exist or not! it will rewrite the URL!
your problem is simple one that too many others have it! DO NOT put /
in begining of rewriterule arguments!
Options FollowSymLinks
RewriteEngine On
RewriteRule ^hosted/essws/([^/]*)/$ hosted/essws/?key=$1 [L]
I struggled for a while trying to do:
RewriteEngine On
RewriteRule ^catalog/([0-9]+)/?$ catalog.php?id=$1 [NC,L]
In my case, catalog.php exists as a file. By removing MultiViews, existing files are no longer a problem for rewriterules.
Options -MultiViews
RewriteEngine On
RewriteRule ^catalog/([0-9]+)/?$ catalog.php?id=$1 [NC,L]
Done!
精彩评论