2011-07-28 99 views
0

在過去的2個小時裏,我一直在解決這個問題,並試圖自己弄清楚。你不這樣做。.htaccess URL重寫問題

所以...我想重寫我的網址(www.domain.com/article/hello)到www.domain.com/article/read/hello,但我似乎無法弄清楚。 我目前的.htaccess:

Options +FollowSymLinks 
RewriteEngine On 
RewriteBase/

#problem here 
RewriteRule ^article\/(.*)$ index.php/article/read/$1 [L] 

RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond %{REQUEST_FILENAME} !-f 
#this has to stay the same and it's actually working 
RewriteRule ^(.*)$ index.php/$1 [L] 

如果我嘗試重定向,因爲它是應該(在規則中加入R)不工作規則 - >一切工作正常的,但是這不是重點,我不希望它重定向。

回答

0

您的.htaccess適合我,我認爲它也適用於您,因爲您認爲它適用,如果您使用重定向進行操作。

我補充說,規則和去localhost/article/hello,然後添加echo $_SERVER['PATH_INFO'];到我的index.php頂部只是爲了測試我也許你正在使用類似REQUEST_URI其中包含的/article/hello代替PATH_INFO/article/read/hello

在你的index.php裏面,這就是爲什麼它看起來不工作?

+0

我在錯誤的地方看了2個小時。噢..謝謝,改變了我的REQUEST_URI,它現在很好用! – MJA

+0

@一個包我很高興它現在爲你工作:) – Paulpro