我得到了以下htaccess
domain.com/param1/param2
到
domain.com/foo.php?bar=param1&baz=param2
但如果用户进入
domain.com/search
和search.php存在,我想去
domain.com/search.php
的.htaccess
IndexIgnore */*
RewriteEngine on
#RewriteCond %{HTTP_HOST} !^domain.com [NC]
#RewriteRule ^/?(.*)$ http://domain.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [L]
RewriteRule ^([a-zA-Z0-9_-]*)$ foo.php?bar=$1 [L]
RewriteRule ^([a-zA-Z0-9_-]*)/([a-zA-Z0-9_-]*)$ foo.php?bar=$1&baz=$2 [L]
<Files .htaccess>
order allow,deny
deny from all
</Files>
答案 0 :(得分:0)
您可以使用:
IndexIgnore */*
RewriteEngine on
#RewriteCond %{HTTP_HOST} !^domain.com [NC]
#RewriteRule ^/?(.*)$ http://domain.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^.*$ - [L]
RewriteCond %{DOCUMENT_ROOT}/$1\.php -f [NC]
RewriteRule ^(.+?)/?$ $1.php [L]
RewriteRule ^([\w-]+)/?$ foo.php?bar=$1 [L,QSA]
RewriteRule ^([\w-]+)/([\w-]+)/?$ foo.php?bar=$1&baz=$2 [L,QSA]
<Files .htaccess>
order allow,deny
deny from all
</Files>