apache - 明显重写的 URL 重写(更改地址栏中的 URL)

标签 apache url mod-rewrite url-rewriting friendly-url

我之前问过这个问题的补充:

Mod_rewrite invisibly: works when target is a file, not when it's a directory

现在我实际上希望重写发生明显,因为我已经切换了 URL 方案,虽然我希望旧链接工作,但我希望用户看到新的 URL 方案。

所以这有效

RewriteRule ^oldscheme/(.*)/?$  newscheme/$1

但是地址栏中的 URL 仍然是 http://example.com/oldscheme/foo .

什么是进行可见重写的正确方法,最好只使用 mod_rewrite 而不是使用位置重定向或类似的东西?

最佳答案

由于我现在无法发表评论,我将在此处发布我对 Ignacio 评论的补充。

您实际上应该发布 301(永久移动)重定向,因为您正在描述有一个新的站点目录结构。所以你的 RewriteRule 应该读

RewriteRule ^oldscheme/(.*)/?$  newscheme/$1  [R=301]

关于apache - 明显重写的 URL 重写(更改地址栏中的 URL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2088411/

相关文章:

apache - 如何调试 Apache mod_rewrite

linux - 禁止通过IP服务器访问网站

javascript - URL 中的尾随哈希 (#) 会破坏某些 Javascript?

url - 如何在 Laravel 4 中获取域根 url?

apache - RewriteCond 的不区分大小写的文件检查

regex - .htaccess 重写 URL 启动/重定向

java - apache commons-fileupload 是否总是必须写入磁盘?

apache - 如何在 From() 中使用动态 URI

php - 编辑 httpd.conf 以在 mac 上使用 apache 服务器

html - 组合 div :after with url link and hover selector