RewriteRule for forwarding all the requests to all the folders to a specific folder.

Discussion in 'Apache' started by glencai, Jan 20, 2011.

  1. #1
    I want to forward all the requests to all the folders of a domain to a specific folder:
    For Example,

    mydomain.com/abc => mydomain.com/myfolder/my.html
    mydomain.com/xyz => mydomain.com/myfolder/my.html
    mydomain.com/123 => mydomain.com/myfolder/my.html
    ....
    mydomain.com/{all the folders} => mydomain.com/myfolder/my.html

    How should I add a RewriteRule in .htaccess to do it?

    Thanks.
     
    glencai, Jan 20, 2011 IP
  2. mysqlxpert

    mysqlxpert Greenhorn

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    Not tested, but it will be something like this

    RewriteEngine On
    RewriteRule ^(.+)/?$ mydomain.com/myfolder/my.html [R=301,L]

    Add R=301 to redirect the URL permanent.
     
    mysqlxpert, Jan 24, 2011 IP