ds3016 2015-05-12 08:13 采纳率: 100%
浏览 88

Laravel 5 mod_rewrite无效

/etc/apache2/apache2.conf

<Directory />
        Options FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

<Directory /usr/share>
        AllowOverride All
        Require all granted
</Directory>

<Directory /var/www/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>

And then in my Laravel public folder:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes...
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>

URL: http://sub.domain.se/user/login does not work.

But http://sub.domain.se/index.php/user/login

works.

When writing: apachectl -M

rewrite_module (shared) is included

In sites-enabled:

<VirtualHost *:80>
        ServerName sub.domain.se
        DocumentRoot /var/www/project/public
</VirtualHost>

What am I missing?

  • 写回答

1条回答 默认 最新

  • douxie7339 2017-02-14 09:33
    关注

    My working .htaccess file is following:

    <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            #Options -MultiViews
        </IfModule>
    
        Options +FollowSymLinks
        RewriteEngine On
    
        # Redirect Trailing Slashes...
        # RewriteRule ^(.*)/$ /$1 [L,R=301]
    
        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </IfModule>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。
  • ¥20 CST怎么把天线放在座椅环境中并仿真
  • ¥15 任务A:大数据平台搭建(容器环境)怎么做呢?
  • ¥15 YOLOv8obb获取边框坐标时报错AttributeError: 'NoneType' object has no attribute 'xywhr'