【问题标题】:htaccess redirect from wrong URL (Laravel)htaccess 从错误的 URL 重定向(Laravel)
【发布时间】:2013-08-21 12:32:40
【问题描述】:

我正在使用 Laravel

很遗憾,Google 获取的网址有误。例如,www.domain.co.uk/article/hello-world 之类的页面已在 Google 中被索引为 www.domain.co.uk/public/index.php/article/hello-world

当您访问该站点时,所有 URL 似乎都是正确的,并且 www.domain.co.uk/article/hello-world URL 按预期显示页面,但我猜 Google 机器人正在使用 .htaccess 并查看长 URL

(我把Laravel自带的public文件夹放在public_html中)

public_html 中的 .htaccess 有:

RewriteEngine On
Options +FollowSymlinks
Options -Indexes
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) /public/$1 [l]

public_html/public 文件夹中还有一个额外的.htaccess

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

有人知道这个问题的任何解决方案吗?

public/index.php 是 URL 时,我尝试重写规则来重定向 URL,但我的运气为零。任何提示将不胜感激。

【问题讨论】:

  • 这对于本网站来说可能有点离题,也许 serverfault 会提供更好的答案。不过,我可以给您的一个提示是转到 Google 的网站管理员工具 google.com/webmasters,您可以选择直接使用 google 解决问题

标签: .htaccess redirect laravel


【解决方案1】:

如果您的主机强制您将文件仅包含在文档根目录中,那么您肯定只需要在根目录中添加一个.htaccess 文件吗?

将文件从public/移动到根目录,并将规则更改为:

RewriteRule ^ public/index.php [L]

【讨论】:

    猜你喜欢
    • 2012-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-25
    • 2013-11-26
    • 1970-01-01
    • 1970-01-01
    • 2020-12-03
    相关资源
    最近更新 更多