简体   繁体   English

.htaccess重定向/更改URL

[英].htaccess Redirect / Change URL

I am having a trouble figuring out how to successfully use mod_rewrite to rewrite my urls for me. 我在弄清楚如何成功使用mod_rewrite为我重写url时遇到了麻烦。

Basically google has indexed my webstore, and now i have rebuilt it at a seperate location and none of the google links work. 基本上,谷歌已经索引了我的网上商店,现在我已经在一个单独的位置对其进行了重建,并且所有的谷歌链接都无法正常工作。 Rather then go through google and set customURLs for my whole site i want to add some .htaccess code to redirect to my new store instead, but it needs to maintain the whole link, this is where im lost. 而是通过google并为我的整个站点设置customURLs,我想添加一些.htaccess代码来重定向到我的新商店,但是它需要维护整个链接,这是我丢失的地方。

My old store was at 我的老店在

http://mystore.com/store/

My new store is at 我的新店在

http://mystore.com/shop/

So when users go to 因此,当用户转到

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

I need them to be reirected to 我需要他们重新接任

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

However, I need an exception to this rule to be my admin area. 但是,我需要对此规则设置例外才能成为我的管理区域。 So if i access: 因此,如果我访问:

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

I DO NOT want to end up at 希望在结束了

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

Because i still need accesss to my old admin panel. 因为我仍然需要访问旧的管理面板。 Thanks in advance for any help! 在此先感谢您的帮助!

Hopefully this does what you're after. 希望这能满足您的需求。

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

Let me know if it works for you :-) 请让我知道这对你有没有用 :-)

Edit: 编辑:

Hopefully this'll work. 希望这会起作用。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM