重定向http://example.com到http:/www.example.com同时保持http://subdomain.example.com完整的访问

编程入门 行业动态 更新时间:2024-10-23 06:30:14
本文介绍了重定向example到http:/www.example同时保持subdomain.example完整的访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有我已经启用子域名访问一个网站,例如:

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 On

EDIT2

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 *:80

2)所有标记:

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完整的访问

本文发布于:2023-11-01 11:42:21,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549250.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   完整   www   http   subdomain

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!