【问题标题】:Redirect Old URL to New URL open cart using htaccess使用 htaccess 将旧 URL 重定向到新 URL 打开购物车
【发布时间】:2015-06-11 02:56:37
【问题描述】:
我想将 301 旧网址重定向到新网址。
我的旧网址是;
http://www.domainname.com/special
新的网址是;
http://www.domainname.com/offers
我试过这段代码:
redirect 301 /http://www.domainname.com/special http://www.domainname.com/offers
但现在它仍然没有将我重定向到不存在的旧 URL。
【问题讨论】:
标签:
.htaccess
mod-rewrite
redirect
opencart
【解决方案1】:
试试这个:
Redirect 301 /special /offers
Redirect Directive 的第二个参数是 URL Path,它不以 Scheme 和主机名开头。
【解决方案2】:
有多种方法可以做到这一点和各种重定向,我在下面列出了它们:
301(永久)重定向:将整个网站永久指向不同的 URL。这是最常见的重定向类型,在大多数情况下都很有用。在本例中,我们重定向到“example.com”域:
这允许您将整个网站重定向到任何其他域
Redirect 301 / http://example.com/
302(临时)重定向:将整个站点指向不同的临时 URL。当您有一个临时着陆页并计划在以后切换回您的主着陆页时,这对于 SEO 很有用:
这允许您将整个网站重定向到任何其他域
Redirect 302 / http://example.com/
将 index.html 重定向到特定的子文件夹:
这允许您将 index.html 重定向到特定的子文件夹
Redirect /index.html http://example.com/newdirectory/
将旧文件重定向到新文件路径:
将旧文件路径重定向到新文件路径
Redirect /olddirectory/oldfile.html http://example.com/newdirectory/newfile.html
重定向到特定的索引页面:
提供特定索引页面(设置默认处理程序)
DirectoryIndex index.html