【问题标题】:Duplicated uri when in subdirectory在子目录中重复的uri
【发布时间】:2022-08-22 22:44:33
【问题描述】:

我有一个必须放在子目录中的 Laravel 应用程序。使用 Apache,我发现了一个有效的 VirtualHost 虚拟主机是:

<VirtualHost *:80>
    ServerName bar.localhost
    Alias /foo /home/me/foo/public
    <Directory /home/me/foo/public>
        AllowOverride All
        Require all granted
    </Directory>
</VirtualHost>

当我转到 \"http://bar.localhost/foo\" 时,页面被加载,另一个 \"foo\" 被添加到 URL (http://bar.localhost/foo/foo),这给应用程序重定向返回带来了很多麻烦。

.env 文件中的 APP_URL 是 \"http://bar.localhost/foo\"

.htaccess:

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

    RewriteEngine On

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

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

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

    标签: laravel apache


    【解决方案1】:

    你解决问题了吗?我有同样的问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-30
      • 1970-01-01
      • 1970-01-01
      • 2020-11-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-07
      相关资源
      最近更新 更多