我有我已经启用子域名访问一个网站,例如:
I have a website on which I've enabled subdomain access such as:
subdomain1.example访问相同的code,但传递域参数,以显示不同的微型网站。在httpd.conf code表示如下:
which accesses the same code, but passing a domain parameter in order to show a different microsite. The httpd.conf code for that looks like this:
RewriteCond %{HTTP_HOST} ^([^./]+)\.example\$ RewriteRule forums.html$ /browse.php?type=forums&domain=%1 [QSA]现在我需要 example 重定向到的 www.example
Now I need to redirect example to www.example
我想这一点,但它没有工作:
I tried this, but it did not work:
RewriteCond %{HTTP_HOST} ^example\ RewriteRule ^(.*)$ www.example/$1 [R=301,L](来源: www.cyberciti.biz/常见问题/ apache的重定向消息domaincom到wwwdomaincom / )
EDIT1
<VirtualHost IPADDRESS:80> ServerAlias *.example DocumentRoot /var/www/html/abc ServerName www.example UseCanonicalName OnEDIT2
mreithub
我需要的设置是这样的:
The setup I need is something like this:
X1.example 应该使用code在/事/ X1
X1.example should use the code in /something/X1
X2.example 应该使用code在/事/ X2
X2.example should use the code in /something/X2
example 应该重定向到的 www.example
www.example/scriptA.php 应该使用code在/var/www/html/abc/scriptA.php
www.example/scriptA.php should use the code in /var/www/html/abc/scriptA.php
whateverelse.example/scriptA.php 应该使用code在/var/www/html/abc/scriptA.php但与'域= whateverelse'参数传递(但屏幕上的网址应显示始终显示域是的 whateverelse.example )
whateverelse.example/scriptA.php should use the code in /var/www/html/abc/scriptA.php but be passed with a 'domain=whateverelse' parameter (but the URL on screen should show always show the domain as being whateverelse.example )
我问过的SF一个问题 - serverfault/questions/408805/configuring-httpd-conf-to-handle-wildcard-domains-with-multiple-scripts - 从那里我用ADAPTR的技术域的参数传递到PHP脚本
I had asked a question on SF - serverfault/questions/408805/configuring-httpd-conf-to-handle-wildcard-domains-with-multiple-scripts - from where I used adaptr's technique to pass the domain parameter to the PHP scripts.
推荐答案哇。 3个小时后...变化很多,很多的学习收获的。
Wow. 3 hours later... Lots of changes, lots of learnings.
1)改变了这种
NameVirtualHost IPADDRESS:80要:
NameVirtualHost *:802)所有标记:
2) Marked all:
<VirtualHost IPADDRESS:80>为:
<VirtualHost *:80>3)重排服务器名,把它先内的虚拟主机(不知道这什么不同)
3) Rearranged ServerName and placed it first within the VirtualHost (not sure if this made any difference)
<VirtualHost *:80> ServerName test4.example ServerAlias test4.example DocumentRoot /home/test4/public_html UseCanonicalName On </VirtualHost>3)重排所有VirtualHosts。放置在静态/固定的子域前面和包罗万象/ WWW一个作为最后一个。最后一个是这样的:
3) Rearranged all VirtualHosts. Placed the 'static' / fixed subdomains earlier and the catch-all / www one as the last one. The last one looks like:
<VirtualHost *:80> ServerName www.example ServerAlias example *.example DocumentRoot /var/www/html/abc UseCanonicalName On ...更多推荐
重定向http://example.com到http:/www.example.com同时保持http://subdomain.example.com完整的访问
发布评论