[英]htaccess index.php redirect to root
好的,我有几个关于htaccess的问题。
首先,我希望website/index.php
成为website/
即使有人在最后输入index.php
。
其次,我想删除.php
即使你键入它并添加/
末website/about-us.php
到website/about-us/
。
我添加了这个以删除末尾的扩展名:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
除了没有100%确定如何添加/
,并且我发现将index.php
更改为url的根目录的所有内容对我来说都不起作用。
尝试这个
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ $1.php
RewriteRule ^([^/]+)/([^/]+)/$ /$1/$2.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
试试这个规则,
DirectoryIndex index.php
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^index.php$ www.{HTTP_HOST}/ [R=301]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.