• 请不要在回答技术问题时复制粘贴 AI 生成的内容
zzw1998
V2EX  ›  程序员

如何利用 Apache rewrite 来隐性跳转

  •  
  •   zzw1998 · Sep 6, 2017 · 2201 views
    This topic created in 3229 days ago, the information mentioned may be changed or developed.

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

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

    好久没写了,不知道对不对
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1063 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 18:55 · PVG 02:55 · LAX 11:55 · JFK 14:55
    ♥ Do have faith in what you're doing.