我目前正在使用自定义MVC架构来创建我的网站。
问题是当我输入localhost / website /(将来将是www.website.com/)时,我希望显示我的主页。目前,我正在通过使用localhost / website / home /来进行此项工作,但我不希望这样做,我只希望localhost / website /会自动显示主页。
我试图用htaccess做到这一点,但没有成功。当我导航到localhost / website /时,显示错误“此网页不可用”。
我的htaccess代码:可在我的公用文件夹中找到。
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
我希望这有道理,希望有人可以帮助我。
谢谢
您可以有一个这样的新规则:
<IfModule mod_rewrite.c>
RewriteEngine On
# handle home page
RewriteRule ^/?$ home [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>
<IfModule !mod_rewrite.c>
ErrorDocument 404 index.php
</IfModule>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句