在过去的两个小时里,我一直在与这个问题作斗争并试图自己解决这个问题。不要这样做。
所以...我想将我的网址(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 :(得分:0)
您的.htaccess
对我有用,我认为它也适合您,因为如果您使用重定向进行此操作,它也会有效。
我添加了该规则并转到localhost/article/hello
,然后将echo $_SERVER['PATH_INFO'];
添加到我的index.php顶部,以便进行测试,我得到了/article/read/hello
也许你在index.php中使用REQUEST_URI
之类的内容包含/article/hello
而不是PATH_INFO
,这就是为什么它看起来不起作用了?