2011-11-27 286 views
0

我一直在嘗試將舊網站的舊網頁重定向到永久重定向的相應新網頁。 以及重定向www.example.comexample.com.htaccess去除www。 AND redirect

我不似乎能夠在瞬間在同一時間

一舉兩得重定向從EX www.example.com/correctlink正確的鏈接作品example.com/correctlink 但只有example.com/Info.aspx被重定向到example.com/about-magento-demo-store和不www.example.com/Info.aspx

*更新

我想刪除WWW。並將40-50個具體地址重定向到新的特定地址。我的問題是,重定向只適用於谷歌保存舊鏈接沒有Www。如果Google已經存儲了包含www的鏈接。那麼我的重定向重定向永久example.com/tabid/61/CategoryID/13/ProductID/64/Default.aspx /index.php/solpaneler/re不起作用 - *更新

我的htaccess看起來有點像這樣 (與最終的幾行是在存在之前,我開始編輯) (我也試着廣告一行Redirect permanent http://www.example.com/Info.aspx http://example.com/about-magento-demo-store但是它沒有功能)

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example\.com 
RewriteRule ^(.*)$ http://example.se/$1 [R=301,QSA,L] 
Options +FollowSymLinks 
RewriteEngine on 
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] 
RewriteCond %{HTTPS}s ^on(s)| 
RewriteRule^http%2://%1%{REQUEST_URI} [L,R=301] 
Redirect permanent /Info.aspx /about-magento-demo-store 
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] 
RewriteRule .* index.php [L] 

回答

0

只需使用重寫規則的一切。重寫規則和Redirect不總是混合良好。

RewriteRule ^Info\.aspx$ /about-magento-demo-store [L,R=301] 
+0

太棒了!但我有一個靜態列表,其中包含特定鏈接,我想將它們重定向到特定頁面。是否有可能通過靜態鏈接製作大量重新編寫的程序? –

+0

你可以這樣做。在apache出現性能問題之前,你需要大量的重寫過程。所以保持簡單。 – Gerben

+0

像下面那樣? RewriteCond http://ww.example.com/ProductID/64/Default.aspx rewriteRule http://example.com/index.php/solpaneler/default.html RewriteCond http://ww.example.com /ProductID/65/Default.aspx rewriteRule http://example.com/index.php/solpaneler2/default.html .............並繼續像這樣約50個鏈接。 ... 感覺靜態變量很奇怪!? –

0

我有同樣的問題looooooooong前的時間。這裏是我的RewriteRules樣本:

# If domain name doesn't end with .com redirect to .com: 
RewriteCond %{HTTP_HOST} (.*)\.(fr|net|org|eu) [NC] 
RewriteRule (.*) http://%1.com$1 [R=301,L] 

# If domain name without "www", add them: 
RewriteCond %{HTTP_HOST} ^mydomainname\.(fr|com|net|org|eu) [NC] 
# Ca signifie forcément que c'est sans www => forcer redirection : 
RewriteRule (.*) http://www.mydomainname.%1$1 [QSA,R=301,L] 

NB:讓您確定您的域名始終以「www」的開始將這個對你的重寫規則的頂部,因爲它應該先天下之憂處理

請注意,它只有在「空」時纔會重定向mydomainname,即沒有任何後面。它不會觸及像http://abc.mydomainname.com這樣的URL,並且它不會觸及像http://abc.def.mydomainname.com

這樣的URL請告訴我它是否有效。

+0

這是一個美麗的腳本,但它不能解決我的問題。我想刪除www。並將40-50個具體地址重定向到新的特定地址。我的問題是,重定向只適用於谷歌保存舊鏈接沒有Www。如果Google已經存儲了包含www的鏈接。那麼我的重定向重定向永久http://www.example.com/tabid/61/CategoryID/13/ProductID/64/Default.aspx /index.php/solpaneler/re不起作用 –

+0

如果是這樣,我可以請你相應地更新你的問題? –

+0

:-)我認爲這是我在問題中提出的問題:-)但是,好吧,我會盡量讓它更清晰 –