doucheng2053 2017-03-04 08:51
浏览 129
已采纳

的.htaccess; 重定向do子目录而不显示在URL中

I have multiple domains like:

www.example.com
www.myexample.com
www.this-is-an-example.com

All domains point to the main path / on my server.

How can I point a single domain to a subdirectory on my server without showing un the URL?

I mean instead of www.myexample.com pointing to / on my server it should point to /myexample/ on my server.

So calling www.myexample.com via browser should open /myexample/index.php on my server and NOT /index.php.

And www.myexample.com/some_path/some_file.php should look for /myexample/some_path/some_file.phpnon my server but the URL should remain www.myexample.com/some_path/some_file.php and get changed to www.myexample.com/myexample/some_path/some_file.php

Does anybody know how to do this? I already tried to Google but without success maybe because I don't really know what to search for.

  • 写回答

2条回答 默认 最新

  • drt96856 2017-03-04 09:30
    关注

    You can use this rule

    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^(www\.)?myexample\.com$
    RewriteRule !folder /folder%{REQUEST_URI} [L]
    

    This will internally forward www.myexample.com or myexample.com (non-www) with requested uri to /folder

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?