如何在我的网址中编写多个参数?
我不想在RewriteRule中写入所有参数,这些参数很复杂,并且不容易匹配我网站中的所有网址,我想为每个参数写一行,但它不起作用。
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]
答案 0 :(得分: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中删除。