【问题标题】:Using Apache to silently redirect requests使用 Apache 静默重定向请求
【发布时间】:2011-11-01 10:43:23
【问题描述】:

我实际上是在使用 php 发送“301 Moved Permanently”标头并将用户重定向到易于阅读的地址:

www.mywebsite.comwww.mywebsite.com/home

有没有办法用 Apache 做到这一点?

  1. 用户正在请求一个网址

  2. 服务器读取 .htaccess 文件并准备正确的页面(/mywebsite/home/index.html 而不是 /mywebsite/index.html

  3. 它发送用于警告浏览器新 URL 为 www.mywebsite.com/home(不使用任何 JavaScript)的页面和适当的标头

【问题讨论】:

  • 如果我明白你想要做什么,你需要这样的东西:RewriteRule ^/$ /home [L,R=301] ;)

标签: apache mod-rewrite redirect


【解决方案1】:

随着时间和经验的增长,我可以回答自己的问题, 希望这会帮助开始使用 apache 的用户:

RewriteEngine on
RewriteRule ^$ /home [R=301,L]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-02-12
    • 1970-01-01
    • 1970-01-01
    • 2010-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-12
    相关资源
    最近更新 更多