![](/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.