我使用这个简单的规则从我网站的 URL 中删除 index.php
:
RewriteRule ^.*$ ./index.php
因此 http://example.com/index.php/user/me
变成 http://example.com/user/me
。
我是否需要添加 [R=301]
以避免从 SEO 的角度来看“内容重复”问题?
最佳答案
您可以添加此规则来避免这种情况:
RewriteCond %{THE_REQUEST} \ /index\.php/([^\?\ ]*)
RewriteRule ^ /%1 [L,R=301]
它将把使用 /index.php
的请求重定向到没有的请求。然后,您已经拥有的规则将在内部重写 index.php。
关于apache - htaccess 美化 URL 需要加 301 重定向吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33111424/