我想使用 htaccess 從 URL 中洗掉所有 .php 擴展名,但也重定向例如以下代碼將洗掉所有 .php 擴展名,但example.com/profile.php?user=test由于單個檔案(profile.php)重定向而出現 500 錯誤example.com/profile/test
<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.
uj5u.com熱心網友回復:
請添加此代碼,它將用戶引數重定向到 url。
<IfModule mod_rewrite.c>
Options FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /
RewriteRule ^profile/([^/] )?$ profile.php?user=$1 [L,QSA]
</IfModule>
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/480699.html
