1

如何在我的网址中写入多个参数?
我不想在 RewriteRule 上写入所有参数,这很复杂且不容易匹配我网站中的所有 url,我想为每个参数写一行,但它不起作用。

http://www.laji.com/p/hello-p-1002.html
(http://www.laji.com/index.php?main_page=product_info&products_id=1002)
RewriteRule ^(.*)-p-(\d+).html$ index.php?main_page=product_info&products_id=$2 [QSA,L]

http://www.laji.com/fr/p/hello-p-1002.html
(http://www.laji.com/index.php?main_page=product_info&products_id=1002&language=fr)
RewriteRule ^/([\w]{2})(.*)$ $2?language=$1 [QSA,L]

http://www.laji.com/fr/c/shoe-c10/
(http://www.laji.com/index.php?main_page=index&cPath=10&language=fr)
RewriteRule ^(.*)-c(\d+)(.*)$ index.php?main_page=index&cPath=$2 [QSA,L]
4

1 回答 1

1

尝试:

# http://www.laji.com/p/hello-p-1002.html
RewriteRule ^p/(.*)-p-([0-9]+)\.html$ /index.php?main_page=product_info&products_id=$2 [QSA,L]

# http://www.laji.com/fr/p/hello-p-1002.html
RewriteRule ^(\w{2})/p/(.*)-p-([0-9]+)\.html$ /index.php?main_page=product_info&products_id=$3&language=$1 [QSA,L]

# http://www.laji.com/fr/c/shoe-c10/
RewriteRule ^(\w{2})/c/(.*)-c([0-9]+)/?$ /index.php?main_page=index&cPath=$3&language=$1 [QSA,L]

您想从正则表达式中省略前导斜杠,因为在从 htaccess 文件应用规则时,它已从 URI 中删除。

于 2013-10-24T01:58:31.517 回答