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条)

报告相同问题?

悬赏问题

  • ¥50 adb连接不到手机是怎么回事?
  • ¥20 抓取数据时发生错误: get_mooncake_data() missing 1 required positional argument: 'driver'的问题,怎么改出正确的爬虫代码?
  • ¥15 vs2022无法联网
  • ¥15 TCP的客户端和服务器的互联
  • ¥15 VB.NET操作免驱摄像头
  • ¥15 笔记本上移动热点开关状态查询
  • ¥85 类鸟群Boids——仿真鸟群避障的相关问题
  • ¥15 CFEDEM自带算例错误,如何解决?
  • ¥15 有没有会使用flac3d软件的家人
  • ¥20 360摄像头无法解绑使用,请教解绑当前账号绑定问题,