我试图修改我的网站网址,以更好的搜索引擎优化。到目前为止,我的情况如下:
RewriteRule ^page-([0-9]+)/?$ /index.php?p=$1 [L,QSA,NC]我想要http://www.domain.com/page-10而不是http://www.domain.com/index.php?p=10
但是如何匹配http://www.domain.com/category/index.php?p=2并将其重写到http://www.domain.com/category/page-2
发布于 2015-09-28 06:05:01
您可以为/category/制定另一条规则
RewriteRule ^(category)/page-(\d+)/?$ $1/index.php?p=$1 [L,QSA,NC]
RewriteRule ^page-(\d+)/?$ index.php?p=$1 [L,QSA,NC]您甚至可以使用将这两个规则合并为一个正则表达式。
RewriteRule ^(category/)?page-(\d+)/?$ $1index.php?p=$2 [L,QSA,NC]发布于 2015-09-28 06:12:13
将http://www.domain.com/category/index.php?p=2更改为http://www.domain.com/category/index.php?p=page-2并重写htaccess以匹配:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^category/([0-9]+)-([a-z]+) http://www.domain.com/category/index.php?p=$1-$2 [NC]https://stackoverflow.com/questions/32816465
复制相似问题