开发者

htaccess rewrite everything but index and root

开发者 https://www.devze.com 2023-01-05 22:06 出处:网络
I\'m trying to set up a site that forwards everything but the root directory and index into a variable. I have the htaccess file set up like this right now:

I'm trying to set up a site that forwards everything but the root directory and index into a variable. I have the htaccess file set up like this right now:

Options +FollowSymlinks
RewriteEngine on

RewriteRule -(.*)$ http://blah.com/blah.php?name=$1 [R,NC]

just so that the index works and anything that starts with a hyphen(-) is rewritten

I would like to be able to have anything that isn't the i开发者_Python百科ndex file rewritten, and still allow the index file be accessed via blah.com and blah.com/

Any ideas?


Try this :

RewriteCond %{REQUEST_URI}   !^/index.php$
RewriteCond %{REQUEST_URI}   !^/blah.php
RewriteCond %{REQUEST_URI}   !^$
RewriteRule ^(.*)         http://blah.com/blah.php?name=$1 [R,NC]


If by any chance you still haven't figured this out, this should work:

RewriteCond %{REQUEST_URI} !^(/|/index.php|/blah.php)$
RewriteRule ^(.*)$ blah.php?name=$1 [R]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号