Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php .htaccess;重定向do子目录而不在URL中显示_Php_Apache_.htaccess_Redirect_Mod Rewrite - Fatal编程技术网

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.commyexample.com(非www)与请求的uri转发到/文件夹您可以使用此规则

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?myexample\.com$
RewriteRule !folder /folder%{REQUEST_URI} [L]
这将在内部将www.myexample.commyexample.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,它也匹配。。。等