2012-09-23 294 views
1

我遇到問題了解如何成功使用mod_rewrite來爲我重寫我的url。.htaccess重定向/更改URL

基本上谷歌已經索引我的網上商店,現在我已經重建了它在一個單獨的位置,沒有任何谷歌鏈接工作。相反,然後通過谷歌,併爲我的整個網站設置customURLs我想添加一些.htaccess代碼重定向到我的新商店,但它需要保持整個鏈接,這是我失去了。

我的老店在

http://mystore.com/store/ 

我的新店是在

http://mystore.com/shop/ 

因此,當用戶去

http://mystore.com/store/categories/cheese/Mouldy/?page=5&sort=featured 

我需要他們reirected到

http://mystore.com/shop/categories/cheese/Mouldy/?page=5&sort=featured 

但是,我需要這個規則的例外是我的管理區域。所以,如果我訪問:

http://mystore.com/store/admin/ 

不要想在

http://mystore.com/shop/admin/ 

結束,因爲我還需要accesss我的舊的管理面板。 在此先感謝您的幫助!

回答

1

希望這不會影響到你。

RewriteCond %{REQUEST_URI} !^store/admin(/|$) 
RewriteRule ^store/(.*)$ ^shop/$1 [L,R=301] 

讓我知道它是否適合你:-)

編輯:

希望這會工作。

RewriteRule ^store/admin(.*)$ ^store/admin$1 
RewriteRule ^store/(.*)$ ^shop/$1 [L,R=301] 
+0

嘿夥計,這對我的心不是workign,我的.htaccess看起來是這樣的,這是正確的: ' \t RewriteEngine敘述在 的RewriteCond%{REQUEST_URI} ^店/管理 RewriteRule^store /(.*)$^shop/$ 1 [L,R = 301] ' –

+0

我已經更新了我的答案,如果這樣做不行,試圖在store/admin前放一個/ RewriteCond行 – David

+0

仍然沒有賓果:( –