我正在寻找以下情况的解决方案。我想隐瞒以下网址
www.example.com/filename.php?p1=1&p2=2 etc
到
www.exmaple.com/filename/1/2 etc
我设法用index.php做到了这一点,但我还想使用其他文件,而不仅仅是索引。可能吗?这是我目前的代码。
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteBase /
# add .php to access file, but don't redirect
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteCond %{REQUEST_URI} !/$
RewriteRule (.*) $1\.php [L]
RewriteRule ^(filename)/([^/]+)/([^/]+)$ /$1.php?p1=$2&p2=$3 [L,QSA,NC]
ErrorDocument 404 /404.php
# display no errs to user
php_flag display_startup_errors off
php_flag display_errors off
php_flag html_errors off
这适用于删除php。但是如果我在它之后添加参数,它会给我错误500
答案 0 :(得分:0)
在RewriteEngine On
行:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(filename)/([^/]+)/([^/]+)/?$ /$1.php?p1=$2&p2=$3 [L,QSA,NC]