V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
zzw1998
V2EX  ›  程序员

如何利用 Apache rewrite 来隐性跳转

  •  
  •   zzw1998 · 2017-09-06 20:43:32 +08:00 · 1692 次点击
    这是一个创建于 2413 天前的主题,其中的信息可能已经有所发展或是发生改变。

    页面地址是 abc.com/xxx.php ,想让访问 xxx.abc.com 等效于访问 abc.com/xxx.php ,如何才能做到?如果 rewrite 不可以,那么利用 php 该如何写,或者还有没有其他办法?

    2 条回复    2017-09-07 09:04:41 +08:00
    kuke
        1
    kuke  
       2017-09-06 20:54:50 +08:00
    在 conf 配置里设置一下 DirectoryIndex xxx.php
    Famio
        2
    Famio  
       2017-09-07 09:04:41 +08:00
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^abc.com
    RewriteCond %{REQUEST_URI} !^xxx.php$
    RewriteCond %{REQUEST_URI} .php$
    RewriteRule (.*).php$ http://$1.abc.com/ [R]

    好久没写了,不知道对不对
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5463 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 07:20 · PVG 15:20 · LAX 00:20 · JFK 03:20
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.