【问题标题】:Laravel 5 : URL with trailing slashes gets redirected to localhost [duplicate]Laravel 5:带有斜杠的 URL 被重定向到 localhost [重复]
【发布时间】:2015-12-25 01:44:12
【问题描述】:

我可以使用http://localhost/rnd/public/coeg-admin 访问我的网址,但如果我访问http://localhost/rnd/public/coeg-admin/,它会被重定向到http://localhost/coeg-admin

我只关注laravel trailing Slashes redirect to localhostURL with trailing slashes gets redirected to localhost in laravel 5

但它没有按预期工作,这是我的.htaccess

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

    RewriteEngine On

    # Set base URL
    # RewriteBase /rnd/public/
    # RewriteRule ^(.*)/$ /$1 [L,R=301]
    # RewriteCond %{REQUEST_URI} !^

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

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

这是我的apache2.conf

<Directory "/var/www/html/rnd/public">
        Options Indexes FollowSymLinks
        #AllowOverride None
        AllowOverride All
        Require all granted
</Directory>

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

如何,我可以将末尾带有斜杠的网址重定向到末尾不带斜杠的网址?

谢谢,感谢任何帮助。

【问题讨论】:

    标签: php .htaccess laravel-5


    【解决方案1】:

    我做的最简单的方法是从 public/.htaccess 中删除 RewriteRule ^(.*)/$ /$1 [L,R=301]

    不要忘记清除缓存,因为chrome重定向缓存也保存在浏览器中

    【讨论】:

      猜你喜欢
      • 2015-08-26
      • 2016-03-08
      • 2015-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-19
      相关资源
      最近更新 更多