htaccess的规则,在网址的结尾删除的index.php [英] .htaccess rule to remove index.php at the end of urls
本文介绍了htaccess的规则,在网址的结尾删除的index.php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好家伙谁能帮我用的.htaccess规则删除的index.php在网址的结尾
Hello guys can someone help me with a .htaccess rule to remove /index.php at the end of urls
例如,如果有人试图访问:
example if someone try to access:
在-URL-address.html / index.php文件
the-url-address.html/index.php
另外,URL-address.html / index.php文件
another-url-address.html/index.php
他们应该被重定向到:
在-URL-address.html
the-url-address.html
另外,URL-address.html
another-url-address.html
从URL末尾移除的index.php
removing the /index.php from the end of url
推荐答案
您可以在 DOCUMENT_ROOT /的.htaccess
文件中使用这个规则:
You can use this rule in your DOCUMENT_ROOT/.htaccess
file:
# set index.php as the default handler
DirectoryIndex index.php
RewriteEngine On
# remove index.php from the end of URI
RewriteCond %{THE_REQUEST} /index\.php [NC]
RewriteRule ^(.*?)index\.php$ /$1 [L,R=302,NC,NE]
这篇关于htaccess的规则,在网址的结尾删除的index.php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文