[英]How can I simply remove the .php extension using .htaccess only for a specific file?
我已經看到了很多有關如何重定向許多URL以便刪除任何.php擴展名的答案,但這已經給我帶來了一些麻煩。
RewriteRule ^quote/([a-zA-Z0-9]+)/$ index.php?id=$1
RewriteRule ^quote/([a-zA-Z0-9]+)$ index.php?id=$1
我已經將/quotes/1
/quotes/2
等重定向到/index.php?id=1
和/index.php?id=2
等。但是我真正想做的就是簡單地匹配/random/
並使其指向/random.php
,目前的答案似乎都不是那么具體。
謝謝。
要使用.htaccess
刪除.php
擴展名,請使用以下命令:
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^\.]+)$ $1.php [NC,L]
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.