2011-07-28 100 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