Php Apache-使用.htaccess重定向到根文件夹
我对.htaccess文件有问题。我用这种方式配置了它Php Apache-使用.htaccess重定向到根文件夹,php,.htaccess,Php,.htaccess,我对.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:
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我删除了最后一个字符/它会将我返回到根页面wampserver
下面的视频解释了这个问题,会发生什么
录像带▶️
从重写规则中删除斜杠,它应该可以工作。可能会在下面更改。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>
好的,请您分享有关php应用程序的更多详细信息,如您使用或不使用的框架等。您有哪台服务器?是的,您可以在这里下载:
<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>