当我键入domain.com/page.php它不会自动更改为domain.com/page/。此外,对于在子目录中的网页,如果我跟着一个链接到domain.com/sub/1/~~V一切都很好,但如果我在浏览器中键入它重定向到domain.com/1~~V /
When I type domain.com/page.php it doesn't automatically change to domain.com/page/. Also, for the pages in subdirectories, if I follow a link to domain.com/sub/1/ everything is fine, but if I type it in the browser it redirects to domain.com/1/
这是我在.htaccess
This is what i have in .htaccess
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^([^/]+)/$ $1.php
# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(.[a-zA-Z0-9]{1,5}|/)$
RewriteRule (.*)$ /$1/ [R=301,L]
任何想法我应该做的子目录和根目录htaccess的文件吗?我在这个新的。
Any ideas what I should do to htaccess files in the subdirectories and root directory? I'm new at this.
更改规则的顺序。
试试这个:
RewriteEngine on
# Forces a trailing slash to be added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+?[^/])$ /$1/ [R=301,L]
# .php ext hiding
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
上一篇:如何阻止或卷曲的file_get_contents卷曲、file_get_contents
下一篇:的.htaccess的CakePHP的和Joomla的子文件夹/子域文件夹、htaccess、CakePHP、Joomla