Php .htaccess;重定向do子目录而不在URL中显示
我有多个域,如:Php .htaccess;重定向do子目录而不在URL中显示,php,apache,.htaccess,redirect,mod-rewrite,Php,Apache,.htaccess,Redirect,Mod Rewrite,我有多个域,如: www.example.com www.myexample.com www.this-is-an-example.com 所有域都指向我的服务器上的主路径/ 如何在不显示URL的情况下将单个域指向服务器上的子目录 我的意思是,它应该指向我服务器上的/myexample/,而不是www.myexample.com 因此,通过浏览器调用www.myexample.com应该在我的服务器上打开/myexample/index.php,而不是/index.php 和www.myexa
www.example.com
www.myexample.com
www.this-is-an-example.com
所有域都指向我的服务器上的主路径/
如何在不显示URL的情况下将单个域指向服务器上的子目录
我的意思是,它应该指向我服务器上的/myexample/
,而不是www.myexample.com
因此,通过浏览器调用www.myexample.com
应该在我的服务器上打开/myexample/index.php
,而不是/index.php
和www.myexample.com/some_path/some_file.php
应查找/myexample/some_path/some_file.php
非我的服务器,但URL应保持www.myexample.com/some_path/some_file.php
,并更改为www.myexample.com/myexample/some_path/some_file.php
有人知道怎么做吗?我已经尝试过谷歌,但没有成功,可能是因为我真的不知道该搜索什么。你可以使用这个规则
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?myexample\.com$
RewriteRule !folder /folder%{REQUEST_URI} [L]
这将在内部将www.myexample.com或myexample.com(非www)与请求的uri转发到/文件夹您可以使用此规则
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?myexample\.com$
RewriteRule !folder /folder%{REQUEST_URI} [L]
这将在内部将www.myexample.com或myexample.com(非www)与请求的uri转发到/文件夹也尝试以下规则
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ /myexample/$1 [L]
也试试下面的规则
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)$ /myexample/$1 [L]
这将导致一个无限循环,因为domain/myexample也匹配,它将尝试重定向到domain/myexample/myexample,后者也匹配。。。等等…这将导致一个无限循环,因为domain/myexample也匹配,它将尝试重定向到domain/myexample/myexample,它也匹配。。。等