mod_rewrite在Laravel 5中不起作用

时间:2017-12-02 23:48:44

标签: php apache laravel .htaccess mod-rewrite

使用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}]

任何帮助将不胜感激。感谢。

1 个答案:

答案 0 :(得分:0)

您可以使用:

RewriteRule ^test/search/(.*)$ /test/search?m_id=$1&a=1 [QSA, L]

没有左/在htaccess RewriteRule中 并在#Handle Front Controller

之前放置规则