的.htaccess - 子域名重定向到文件夹文件夹、重定向、域名、htaccess

2023-09-02 00:21:34 作者:失去你〆得到世界又如何

这个问题可能已经问了一千次,但我已经尝试过这么多的脚本,而只要用Google搜索,而什么也没找到,我想,我们只是问。

This question has probably been asked for over a thousand times, but I've tried so many scripts, and googled so long while finding nothing, I thought, let's just ask.

我只是想 m.daltonempire.nl 被重定向到 daltonempire.nl/m / 未经用户看到URL的变化。

I simply want m.daltonempire.nl to be redirected to daltonempire.nl/m/ without the user seeing the URL change.

因此​​,如果 m.daltonempire.nl/hello.php 要求,我希望用户一直看到这个URL,而给出的页面实际上是 daltonempire.nl/m/hello.php

So if m.daltonempire.nl/hello.php is requested, I want the user to keep seeing this URL, while the page given is actually daltonempire.nl/m/hello.php.

注:我不想 WWW ,所以干脆 http://m.daltonempire.nl

Note: I do not want www., so simply http://m.daltonempire.nl

在此先感谢,

以赛亚书诉Hunen

Isaiah v. Hunen

推荐答案

我已经设置我下面的子域名CNAME:

I have set CNAME of my sub domain below:

blog.mydomain.com

我的安装文件夹 /博客/ 根目录下的字preSS。

to my wordpress that installed in folder /blog/ under root directory.

以前我需要使用这个网址来调用Word preSS:

Formerly I need to use this url to call wordpress:

http://blog.mydomain.co/blog/

这是丑陋的。我曾尝试过许多code重定向:

which is ugly. I have tried many code to redirect:

http://blog.mydomain.com/

文件夹,所以我可以用它作为我的话preSS网址。

to the folder so I can use it as my wordpress url.

最后,我得到了的.htaccess 的设置,一般的工作:

Finally I got .htaccess setting that is work:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^blog.mydomain.com$
    RewriteCond %{REQUEST_URI} !^/blog/
    RewriteRule (.*) /blog/$1

我也有CNAME其他子域: http://forum.mydomain.com 来MyBB的安装文件夹 /论坛/ MyBB的/ ,以便的.htaccess 需要把 [L] 在每个重写规则code作为下文。

I have also CNAME other subdomain: http://forum.mydomain.com to mybb installation in folder /forum/mybb/ so the .htaccess need to put [L] on each of RewriteRule code as below.

    RewriteEngine On

    RewriteCond %{HTTP_HOST} ^forum.tophyips.info$
    RewriteCond %{REQUEST_URI} !^/forum/mybb/
    RewriteRule (.*) /forum/mybb/$1 [L]

    RewriteCond %{HTTP_HOST} ^blog.tophyips.info$
    RewriteCond %{REQUEST_URI} !^/blog/
    RewriteRule (.*) /blog/$1 [L]

如果你想使用code,请不要忘记设置站点URL和Cookie路径中的应用程序配置文件遵循的设置,使重定向正常工作。

In case you want to use the code please don't forget to set the site url and cookie path in the application config file follow to the setting to make the redirection work properly.