簡體   English   中英

.htaccess opencart redirect 301

[英].htaccess opencart redirect 301

我只是將我的網站從asp遷移到opencart。 在.htaccess中我想做一些重定向,以便我的客戶可以使用舊的鏈接來訪問

在里面.htaccess

redirect 301 /contact.asp http://www.example.com/index.php?route=information/contact_us
redirect 301 /downloads.asp http://www.example.com/downloads

但是,對於完美運行的聯系我們,對於下載網址,它無法正常工作。 當我訪問http://www.example.com/downloads.asp ,它將重定向到http://www.example.com/downloads?_route_=downloads.asp並且Opencart顯示它找不到頁面。 對於http://www.example.com/downloads我們在后端系統中設置了SEO友好URL。

我們能夠訪問

http://www.example.com/information/downloads

http://www.example.com/downloads

但我們無法使用普通鏈接訪問

http://www.example.com/index.php?route=information/downloads

以下是我的全部.htaccess

# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini)">
Order deny,allow
Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

redirect 301 /contact.asp http://www.example.com/index.php?route=information/contact_us
redirect 301 /downloads.asp http://www.example.com/downloads

============另一個測試========================

我在我的localhost上做了一些測試我發現這是一個有趣的結果。 但是,我的問題仍然沒有解決。

我從http:// localhost / examplehttp:// example (添加的虛擬目錄)運行.htaccess

對於http:// localhost / example

redirect 301 /example/downloads.asp http://localhost/example/downloads/

對於http:// example

redirect 301 /downloads.asp http://example/downloads/

然后我嘗試從localhost重定向到我的實時版本鏈接(http:// example)

redirect 301 /downloads.asp http://www.example.com/downloads/

我訪問http://example/downloads.asp

瀏覽器重定向到我

http://www.example.com/downloads? route = downloads.asp

風陵渡

在LIVE版本中,我沒有添加任何重定向代碼[非常可靠]

但在Live版本中,我將直接使用enter訪問

http://www.example.com/downloads

我不知道為什么從localhost重定向301到現場版本會出來

http://www.example.com/downloads? route = downloads.asp

任何想法?

找到解決方案: .htaccess重定向301使用opencart v1.5.4.1

需要額外的代碼...(和此修復的信用): https//github.com/opencart/opencart/pull/142 ...替換內容: - catalog / controller / common / seo_url.php - system /庫/ url.php

Redirect Fine:RewriteRule contacto http:.... com / index.php?route = information / contact [R = 301,L]

重定向不起作用:重定向301 contacto http:.... com / index.php?route = information / contact

驗證。

把它放在路由器前面。 在前面添加.asp和^之后的$。

# Prevent Direct Access to files
<FilesMatch "\.(tpl|ini)">
Order deny,allow
Deny from all
</FilesMatch>

# SEO URL Settings
RewriteEngine On

redirect 301 ^contact.asp$ http://www.example.com/index.php?route=information/contact_us
redirect 301 ^downloads.asp$ http://www.example.com/downloads

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^?]*) index.php?_route_=$1 [L,QSA]

為什么不將聯系人重定向到/information/contact_us而不是index.php?route=information/contact_us

你可以嘗試一下“?” 在重定向url的末尾,如果它不存在,就像第二個url(它對我有用):

redirect 301 /contact.asp http://www.example.com/index.php?route=information/contact_us
redirect 301 /downloads.asp http://www.example.com/downloads?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM