2013-10-24 61 views
1

如何在我的url中寫入多個參數?
我不想寫在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] 

回答

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] 

你想,因爲這是從URI的從htaccess文件應用規則時刪除從您的正則表達式省略斜線。