让我的 htaccess 删除页面的参数以包含更多页面

make my htacces that delete the parameter of the page to contain more page

我无法改进我的 htacces 以包含更多页面

,我有 htacess 删除 Playlist.php?v=1 的参数并将其转换为 Playlist/1

真正的问题是我有超过播放列表页面

我有 5 页更像 Type.php,Videos.php,Watch.php

我试图用不同的参数在 htacces 中加倍相同的代码,但是

我什么都没用

我的 htacces 代码是

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
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= [L,QSA,NC]

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

我通过完全更改代码解决了这个问题 这是我的小解决方案

RewriteEngine On
RewriteRule ^PlayList/([^/]*)$ /PlayList.php?v= [L]
RewriteRule ^Type/([^/]*)$ /Type.php?v= [L]
RewriteRule ^Videos/([^/]*)$ /Videos.php?id= [L]
RewriteRule ^Watch/([^/]*)$ /Watch.php?v= [L]

使用正则表达式交替,您将只需要一个规则而不是 4 个规则:

Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

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

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

RewriteRule ^(PlayList|Type|Videos|Watch)/([^/]+)/?$ .php?v= [L,QSA]

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