Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/5.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
.htaccess:基于TLD从文件夹加载_.htaccess_Redirect - Fatal编程技术网

.htaccess:基于TLD从文件夹加载

.htaccess:基于TLD从文件夹加载,.htaccess,redirect,.htaccess,Redirect,我尝试将功能描述如下: example.com将从webhosting_root/com/加载内容,但URI保持在example.com example.es来自webhosting_root/es/,URI:example.es example.pl来自webhosting_root/pl/,URI:example.pl example.cz来自webhosting_root/cz/,URI:example.cz 所有域都设置为路由到一个网络主机 我认为这是可以通过.htaccess规则实现

我尝试将功能描述如下:

example.com将从webhosting_root/com/加载内容,但URI保持在example.com
example.es来自webhosting_root/es/,URI:example.es
example.pl来自webhosting_root/pl/,URI:example.pl
example.cz来自webhosting_root/cz/,URI:example.cz

所有域都设置为路由到一个网络主机

我认为这是可以通过.htaccess规则实现的?但我不知道如何做到这一点。您能帮忙吗?

找到了解决方案:

.htaccess

RewriteEngine On

RewriteCond %{HTTP_HOST} ^(www\.)?example.com$
RewriteCond %{REQUEST_URI} !^/com/
RewriteRule (.*) /com/$1 [L]

RewriteCond %{HTTP_HOST} ^(www\.)?example.es$
RewriteCond %{REQUEST_URI} !^/es/
RewriteRule (.*) /es/$1 [L]

...