我如何删除.htaccess中的文件参数

时间:2015-08-21 09:44:11

标签: php .htaccess mod-rewrite parameters

我的htaccess文件有问题 问题是:我有像www.example.com/PlayList.php?v=1这样的链接,我需要将其转换为这种方式www.example.com/PlayList/1

我尝试使用此代码,但它没有与我合作,我不知道方式> 没有错误

Options +FollowSymLinks -MultiViews
RewriteEngine On


RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]
 RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]

 RewriteCond %{REQUEST_URI} ^/PlayList/
RewriteCond %{QUERY_STRING} v
RewriteRule (.*) /$1? [R=301,L]

1 个答案:

答案 0 :(得分:3)

您可以使用:

Options +FollowSymLinks -MultiViews
RewriteEngine On

RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} /PlayList\.php\?v=([^\s&]+) [NC]
RewriteRule ^ /PlayList/%1? [R=302,L,NE]

RewriteCond %{REQUEST_METHOD} !POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L]

RewriteRule ^PlayList/(\d+)/?$ PlayList.php?v=$1 [L,QSA,NC]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*?)/?$ $1.php [L]