Q5
V2EX  ›  问与答

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

  •  
  •   Q5 · Mar 18, 2017 · 3069 views
    This topic created in 3518 days ago, the information mentioned may be changed or developed.

    想通过 htaccess 做以下规则跳转

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

    其中 * 是一个通配符

    不知道规则怎么写?

    6 replies  •  2017-03-18 23:17:20 +08:00
    artandlol
    artandlol
    Mar 18, 2017 via Android
    1
    作为一位非开发,觉得应该做 301 跳转。
    Q5
    Q5
    OP
    Mar 18, 2017
    2
    @artandlol 是的,可以规则不会写,网上找的到的,全都不好用
    crab
    crab
    Mar 18, 2017
    3
    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
    Q5
    OP
    Mar 18, 2017
    4
    @crab 似乎并不好使
    lslqtz
    lslqtz
    Mar 18, 2017
    5
    http://jingyan.baidu.com/article/066074d694ab77c3c31cb077.html
    百度一下就知道的东西,为什么要拿出来问...

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^aaa.xxx$ [NC]
    RewriteRule ^(.*)$ http://bbb.xxx/$1 [L,R=301]
    lslqtz
    lslqtz
    Mar 18, 2017
    6
    针对特定目录:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^aaa.xxx$ [NC]
    RewriteCond %{REQUEST_URI} ^/12345/
    RewriteRule ^(.*)$ http://bbb.xxx/12345/$1 [L,R=301]
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   3067 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 11:10 · PVG 19:10 · LAX 03:10 · JFK 06:10
    ♥ Do have faith in what you're doing.