我的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]
答案 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]