我想通过使用apache重写规则将域名重定向到服务器子目录,.How我可以更改.htaccess文件吗?
www.a.com绑定到/a
www.b.com绑定到/b
由于一些跨域问题,我无法更改httpd-vhosts.conf。
/d有一个.htaccess文件,如果删除它,我会捕获404错误,或者我会捕获ERR_TOO_MANY_REDIRECTS。
.htaccess文件:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
发布于 2016-10-26 03:35:44
这里是:(在您的网站根目录上保存为.htaccess )
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(.*)\.com$
RewriteRule ^(.*)$ /full/path/to/document/root/%1/$1 [END]Website,是在apache2/vHost上定义的DocumentRoot。您说要www.a.com重定向到/a,DocumentRoot是到URL路径/的完整系统路径。
这将适用于Apache2.4,而不是2.2。
对第一项评论的答复:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.(a|b|c).com$
RewriteRule ^(.*)$ /full/path/to/document/root/d/$1 [END]
RewriteCond %{HTTP_HOST} ^www.(.*)\.com$
RewriteRule ^(.*)$ /full/path/to/document/root/%1/$1 [END]https://stackoverflow.com/questions/40252926
复制相似问题