.htaccess页面slug read.php?slug=title to/title

.htaccess页面slug read.php?slug=title to/title,.htaccess,mod-rewrite,.htaccess,Mod Rewrite,请帮我修改一下 我有一个网站www.website.com/read.php?slug=我的页面标题 我想重写如下网址:www.website.com/my-page-title 这是我的.htaccess RewriteEngine On RewriteCond %{THE_REQUEST} ^GET\ /read\.php\?slug=([^\s&]+) [NC] RewriteRule ^read\.php$ /%1? [R=301,L] RewriteRule ^/([^/]+

请帮我修改一下

我有一个网站www.website.com/read.php?slug=我的页面标题

我想重写如下网址:www.website.com/my-page-title

这是我的.htaccess

RewriteEngine On
RewriteCond %{THE_REQUEST} ^GET\ /read\.php\?slug=([^\s&]+) [NC]
RewriteRule ^read\.php$ /%1? [R=301,L]

RewriteRule ^/([^/]+)/?$ /read.php?slug=$1 [NC,L]

它向我显示了上述规则的404错误。请协助

您需要从规则中删除前导斜杠,因为RewriteRule的模式与当前目录相关

RewriteRule ^([^/]+)/?$ /read.php?slug=$1 [L]