我需要删除index.php吗?
I need to remove index.php? from URL.
来自: example/index.php?/discover/
收件人: forum.fibaro/discover/
我尝试了一切,但没有用:/
I tried everything, but doesn't work :/
推荐答案我认为您正在尝试针对URI只有这样,让我在这里解释一下:
I think you were trying to mach against URI only so, let me explain something here :
example/index.php?/discover/这部分 index.php 是URI,然后有是?,然后是 / discover / ,最后一部分是查询字符串,因此可以与之匹配 QUERY_STRING或THE_REQUEST 服务器变量根据您的需要,但是在使用 REQUEST_URI 时,您只能匹配URI部分。
This part index.php is URI , then there is ? and after that is /discover/ , the last part is query string so to match against it you could use QUERY_STRING or THE_REQUEST Server-Variables according to what you need but when using REQUEST_URI you match only against URI part.
尝试以下操作:
RewriteEngine On RewriteCond %{THE_REQUEST} ^[A-Z]{3,7}\s/index\.php\?\/(.*)\sHTTP.*$ RewriteRule ^index\.php$ /%1? [L,R=301] RewriteRule !^index\.php$ /index.php?%{REQUEST_URI} [L]上面的代码会将 example/index.php?/discover/ 重定向到 example/discover/ 从外部,然后再次将其重定向到同一路径。
The code above will redirect example/index.php?/discover/ to example/discover/ externally and then redirect it again to same path .
注意:清除浏览器缓存,然后对其进行测试。
Note: clear browser cache then test it .
更多推荐
htaccess删除index.php?从网址
发布评论