【发布时间】:2018-05-16 18:22:16
【问题描述】:
使用 Laravel 5.5 时,尝试访问 http://127.0.0.1:8000/test/search/357 时出现找不到页面错误。没有其他解决方案对我有用。我的 .htaccess 文件位于根目录中,如下所示:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
Options +FollowSymLinks
RewriteEngine On
RewriteBase "/test/"
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/test/ # <=== NEW LINE!!!!
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteRule ^/test/search/(.*)$ /test/search?m_id=$1&a=1 [QSA, L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
任何帮助将不胜感激。谢谢。
【问题讨论】:
-
您有语法错误。您打开 IfModule 两次但只关闭一次。除此之外,我认为在 laravel 中使用 htaccess 重定向而不是路由并正确设置虚拟主机并不是一个好主意。
标签: php apache laravel .htaccess mod-rewrite