Mod Rewrite与Wordpress重写规则相冲突



在我的网站上,有一个带有短代码的页面,在打印内容之前读取 3 个参数。该页面如下所示:

/collaboratori?collaboratore=6&n=Mario&c=Rossi

我想在 SEO 友好的 url 中转换它,如下所示:

/

profilo-collaboratore/6/Mario/Rossi

我正在使用以下 Mod 重写规则

RewriteEngine On
RewriteRule ^profilo-collaboratore/([^/]*)/([^/]*)/([^/]*)$ /collaboratori?collaboratore=$1&n=$2&c=$3 [L]

但是当我尝试加载/profilo-collaboratore/6/Mario/Rossi 时,Web 服务器返回 404 错误代码,Wordpress 向我显示 404 错误页面

我的.htaccess是:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^profilo-collaboratore/([^/]*)/([^/]*)/([^/]*)$ /collaboratori?collaboratore=$1&n=$2&c=$3 [L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

我错在哪里?

非常感谢

看起来正则表达式有问题。

尝试以下规则,它应该有效。

RewriteRule ^/profilo-collaboratore/(w+)/(w+)/(w+) /collaboratori?collaboratore=$1&n=$2&c=$3 [NC]

我通过添加[R]标志来测试它,以便在重定向期间查看重写的 url。

$ curl -IL http://localhost/profilo-collaboratore/6/Mario/Rossi
HTTP/1.1 302 Found
Date: Sat, 24 Jan 2015 15:03:24 GMT
Server: Apache/2.4.10 (Unix) OpenSSL/1.0.1e
Location: http://localhost/collaboratori?collaboratore=6&n=Mario&c=Rossi
Content-Type: text/html; charset=iso-8859-1
HTTP/1.1 404 Not Found
Date: Sat, 24 Jan 2015 15:03:24 GMT
Server: Apache/2.4.10 (Unix) OpenSSL/1.0.1e
Last-Modified: Wed, 24 Dec 2014 08:11:27 GMT
ETag: "13f-50af1d6a1b74d"
Accept-Ranges: bytes
Content-Length: 319
Content-Type: text/html

最新更新