[英]Apache - using .htaccess redirect to root folder
我的.htaccess文件有問題。 我以這種方式配置它。
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)/$ index.php?controller=$1 [L]
每次我訪問http://localhost/mvc3/contacto/
我都訪問http://localhost/mvc3/index.php?controller=contacto
,這是正確的,但是如果友好的URL我刪除了最后一個字符/
( http:// localhost / mvc3 / contacto ),它將返回到根頁面(wampserver服務器)。
在視頻中解釋了此問題,將會發生什么情況?
視頻▶️http : //recordit.co/FfXHww1xCv
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^(.*)$ index.php?controller=$1 [L]
從重寫規則中刪除斜杠,它應該起作用。
可能低於.htaccess的更改將對您有所幫助
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ ^$1 [N]
RewriteCond %{REQUEST_URI} (\.\w+$) [NC]
RewriteRule ^(.*)$ index.php?controller=$1
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
</IfModule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.