V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Q5
V2EX  ›  问与答

想实现这样的 url 跳转,求大神赐予我伪静态的规则

  •  
  •   Q5 · 2017-03-18 20:36:08 +08:00 · 1736 次点击
    这是一个创建于 2602 天前的主题,其中的信息可能已经有所发展或是发生改变。

    想通过 htaccess 做以下规则跳转

    aaa.xxx/12345/*.html 跳转到 bbb.xxx/12345/*.html

    其中 * 是一个通配符

    不知道规则怎么写?

    6 条回复    2017-03-18 23:17:20 +08:00
    artandlol
        1
    artandlol  
       2017-03-18 20:50:40 +08:00 via Android
    作为一位非开发,觉得应该做 301 跳转。
    Q5
        2
    Q5  
    OP
       2017-03-18 21:31:54 +08:00
    @artandlol 是的,可以规则不会写,网上找的到的,全都不好用
    crab
        3
    crab  
       2017-03-18 21:43:16 +08:00
    http://www.htaccesseditor.com/sc.shtml#a_redirect

    <Files ~ "^\.(htaccess|htpasswd)$">
    deny from all
    </Files>
    Redirect permanent aaa.xxx bbb.xxx
    order deny,allow


    看下对不对
    Q5
        4
    Q5  
    OP
       2017-03-18 22:01:06 +08:00
    @crab 似乎并不好使
    lslqtz
        5
    lslqtz  
       2017-03-18 23:15:51 +08:00
    http://jingyan.baidu.com/article/066074d694ab77c3c31cb077.html
    百度一下就知道的东西,为什么要拿出来问...

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^aaa.xxx$ [NC]
    RewriteRule ^(.*)$ http://bbb.xxx/$1 [L,R=301]
    lslqtz
        6
    lslqtz  
       2017-03-18 23:17:20 +08:00
    针对特定目录:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^aaa.xxx$ [NC]
    RewriteCond %{REQUEST_URI} ^/12345/
    RewriteRule ^(.*)$ http://bbb.xxx/12345/$1 [L,R=301]
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1168 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 17:36 · PVG 01:36 · LAX 10:36 · JFK 13:36
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.