1

我正在寻找以下情况的解决方案。我想隐藏以下网址

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

4

1 回答 1

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]
于 2013-06-25T13:53:33.347 回答