URL重写了明显重写(改变URL地址栏) [英] URL rewriting that visibly rewrites (changes the URL in the address bar)
问题描述
我问排序这个问题之前补的:
I asked sort of the complement of this question before:
<一个href=\"http://stackoverflow.com/questions/1685030/modrewrite-invisibly\">http://stackoverflow.com/questions/1685030/modrewrite-invisibly
现在其实我是想重写,能明显发生了,因为我已经打开的URL方案,虽然我想老链接上班,我希望用户看到新的URL方案。
Now I actually want a rewrite to happen visibly, because I've switched URL schemes and although I want the old links to work, I want the user to see the new URL scheme.
所以这个作品
RewriteRule ^oldscheme/(.*)/?$ newscheme/$1
但在地址栏中的URL仍然是 http://example.com/oldscheme/foo
。
什么只是mod_rewrite的是做一个可见重写以正确的方式,preferably,而不是一些缺憾与位置重定向或诸如此类?
What's the right way to do a visible rewrite, preferably just with mod_rewrite as opposed to something kludgy with Location redirects or somesuch?
推荐答案
由于我现在不能发表评论,我会后我除了伊格纳西奥的评论在这里。
As I cannot leave comments now, I'll post my addition to Ignacio's comment here.
您实际上应该张贴301(永久移动)重定向,因为你描述有一个新的站点的目录结构。所以,你应该重写规则阅读
You actually should post a 301 (Moved Permanently) redirect, as you're describing there's a new site directory structure. So your RewriteRule should read
RewriteRule ^oldscheme/(.*)/?$ newscheme/$1 [R=301]
这篇关于URL重写了明显重写(改变URL地址栏)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!