![](/img/trans.png)
[英].htaccess Remove file extension, force trailing slash and allow folder with same name as file
[英].htaccess allow extension, allow no extension, and allow trailing slash
我在编写 htaccess 文件以执行我需要它执行的操作时遇到问题。
这是我到目前为止所拥有的:
RewriteOptions inherit
ErrorDocument 404 http://www.tempsite.com/400.php
ErrorDocument 500 http://www.tempsite.com/500.php
RewriteEngine On
RewriteRule ^index/?$ index.php [NC]
RewriteRule ^pricing/?$ pricing.php [NC]
RewriteRule ^support/?$ support.php [NC]
RewriteRule ^about/?$ about.php [NC]
RewriteRule ^learning/?$ learning.php [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ $1.php [L]
因此,根据我的测试和我的知识,它的作用是:
这就是我想要的但是我不想添加每个页面,例如: RewriteRule ^index/?$ index.php [NC]
每次我创建一个新页面时,我该如何编写一个RewriteRule
来做同样的事情(允许页面带斜线和不带)但对于所有域页面?
您可以使用:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ $1.php [L]
而不是RewriteRule ^index/?$ index.php
的所有行...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.