【问题标题】:how to redirect a 404 page not found in OpenCart using .htaccess如何使用 .htaccess 重定向在 OpenCart 中找不到的 404 页面
【发布时间】:2014-10-11 04:37:34
【问题描述】:

在我的 .htaccess 上:

我尝试使用下面的行代码将 404 页面 about_us 页面重定向到 about-us 页面

redirect 301 /about_us http://www.example.com/about-us

但是当我试图加载到浏览器时,about-us 页面被重定向到该页面到

http://www.example.com/about-us?_route_=about_us但页面仍然出现404错误

这是我的 .htaccess 规则

RewriteBase /
#RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
#RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

【问题讨论】:

  • 您的 .htaccess 中有更多规则吗?如果是,请在此处发布相关问题。
  • 可能是因为 https 版本的网站?

标签: .htaccess http-status-code-404 opencart


【解决方案1】:

不要将redirect 规则与mod_rewrite 规则一起使用。这样做:

RewriteEngine On
RewriteBase /

RewriteRule ^about_us/?$ http://www.example.com/about-us [L,NC,R=301]

#RewriteRule ^sitemap.xml$ index.php?route=feed/google_sitemap [L]
#RewriteRule ^googlebase.xml$ index.php?route=feed/google_base [L]
RewriteRule ^download/(.*) /index.php?route=error/not_found [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !.*\.(ico|gif|jpg|jpeg|png|js|css)
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

确保在新浏览器中测试以避免旧浏览器缓存

【讨论】:

    猜你喜欢
    • 2019-03-03
    • 2013-12-11
    • 2020-10-03
    • 2011-12-05
    • 1970-01-01
    • 1970-01-01
    • 2013-05-17
    • 2023-03-10
    • 2013-01-31
    相关资源
    最近更新 更多