簡體   English   中英

刪除所有 .php 擴展名后的 htaccess 無法重定向單個文件

[英]htaccess after removing all .php extensions can't redirect single files

我想使用 htaccess 從 URL 中刪除所有 .php 擴展名,但也將example.com/profile.php?user=test重定向到example.com/profile/test以下代碼將刪除所有 .php 擴展名,但得到500由於單個文件 (profile.php) 重定向而導致的錯誤

<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]
RewriteRule ^(.*)$ profile.php?user=$1 [QSA,L]

</IfModule>

阿帕奇2日志:

 Request exceeded the limit of 10 internal redirects due to probable configuration error.

請添加此代碼,它將用戶參數重定向到 url。

<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^profile/([^/]+)?$ profile.php?user=$1 [L,QSA]

</IfModule>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM