2016-01-24 94 views
0

我有,我想重寫URL這樣就可以通過類似這樣的如何傳遞多個參數.htacess

參數從www.example.com/questions.php/postid=101&title=htaccess_tuts

www.example.com/questions.php/postid/1/title/htaccess_tuts

我一直試圖使用下面的.htaccess完成這項工作,但我最終得到了這個

www.example.com/questions.php/postid=1&title=htaccess_tuts

www.example.com/questions.php/postid/101

標題部分沒有顯示。 誰能幫我把它傳遞多個參數

RewriteBase/
#Options +FollowSymLinks -MultiViews 
RewriteEngine On 


RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^([^\.]+)$ $1.php [NC,L] 


#here is the problem i have don this but didn't work 
#RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+questions\.php\?postid=([^\s&]+)&([^\s&]+) [NC] 
#What can i do again? 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+questions\.php\?postid=([^\s&]+) [NC] 
RewriteRule^questions/%1? [R=301,L] 
RewriteRule ^questions/([^/]+)/?$ questions.php?postid=$1&title=$2 [L,QSA] 

回答

0
RewriteEngine On 
RewriteRule ^questions\.php/postid/([^/]*)/title/([^/]*)$ /questions.php?postid=$1&title=$2 [L] 

您可以使用this網站生成重寫規則

+0

仍然沒有工作正在我404.php頁面@smoqadam – Codesoft

+0

你可以訪問這個頁面由「www.example.com/questions.php/postid/1/title/htaccess_tuts」網址提供。你嘗試過或使用其他網址? – smoqadam