1

我有一个特定的需求:

example.com/store/{location} 必须重定向到 example.com/store2/{location}

这需要重定向,而不仅仅是一个 url 'rewrite',所以我猜我需要 mod_alias,对吧?有人愿意分享正确的代码吗?我对 mod_rewrite 和 mod_alias 都有些模糊。(我希望我问的正确)谢谢!

4

2 回答 2

2

If you mean you want to tell the browser to redirect its location, you simply can do this with mod_alias:

Redirect /store http://example.com/store2

Or the following if you mean it's a permanent redirect:

RedirectPermanent /store http://example.com/store2

As for your confusion, mod_alias is basically a simpler version of mod_rewrite. Quoting GreyWyvern:

Essentially, if you're doing a "rewrite" which doesn't have any complex conditions attached to it, you should be using mod_alias. Conversely, if you want to redirect requests to files and query strings which you don't want displayed in the browser's address bar, you should be using mod_rewrite

于 2011-05-03T04:49:13.467 回答
1
RewriteRule ^/store/(.*)/$ store2/$1 [R=301,L]
于 2011-04-28T05:25:04.373 回答