2012-08-13 42 views
1

everyone ..在我的友好網址中的案例

我的網址有問題。我重寫我的URL像這個友好的網址。

http://www.lankainstitute.com/1289/Mahesh Jayarathna HTTP/1./?1 

但網址的結束這個字符串 「HTTP/1 ./?1」 增加了..

有誰能夠告訴我這是爲什麼???

這是從我的.htaccess文件

RewriteEngine On 

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /profiles/tutors/index.php\?tutorCode=([0-9]+)&tutorName=([^&]+)&?([^\ ]+) 
RewriteRule ^profiles/tutors/index\.php /%1/%2/?%3 [R=301,L,NE] 

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^([0-9]+)/(.+)/$ /profiles/tutors/index.php?tutorCode=$1&tutorName=$2 [L,QSA] 

任何意見是極大的讚賞..

謝謝。

回答

0

您需要調整%{THE_REQUEST}匹配中的正則表達式。當查詢字符串參數tutorName=something後面沒有任何內容時,請求中HTTP/1.1之前的空格永遠不會匹配,因此它將作爲([^&]+)分組的一部分結束。嘗試調整正則表達式看起來像這樣(並注意在規則中,反向引用需要更改爲%4):

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /profiles/tutors/index.php\?tutorCode=([0-9]+)&tutorName=([^&\ ]+)(&([^\ ]+))? 
RewriteRule ^profiles/tutors/index\.php /%1/%2/?%4 [R=301,L,NE] 
+0

感謝它的工作。但網址'/'結尾添加了這個斜槓。我怎樣才能從我的網址中刪除這個。 (在Tutor Name後面) – ugnuku 2012-08-13 04:30:11

+0

@ user1543817你需要那個,因爲在下面的規則中你特別匹配了一個尾部的斜線:'RewriteRule ^([0-9] +)/(。+)/ $' – 2012-08-13 04:36:35

+0

Jon Lin我不清楚你的評論。你能再次解釋一下嗎...... – ugnuku 2012-08-13 04:51:54