htaccess的将不重写子域 [英] htaccess will not rewrite subdomains

查看:119
本文介绍了htaccess的将不重写子域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我有我的 htaccess的这code 文件存储在根:

I currently have this code in my htaccess file stored in the root:

RewriteEngine On
DirectoryIndex index.php

RewriteCond %{HTTP_HOST} admin.mydom.com$
RewriteRule ^(.*)$ /admin/system/$1 [L]

RewriteCond %{HTTP_HOST} ^([^/.]+)\.mydom\.com$
RewriteRule ^(.+)$ /subdomains/%1/ [L]

RewriteCond %{HTTP_HOST} !mydom.com$ [NC]
RewriteRule ^(.*)$ http://www.mydom.com/$1 [L,R=301]

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

该文件应确保下面是在网站上完成的:

The file should ensure the following is done on the site:

管理​​子域映射到 /管理/系统

映射所有子域 /子域/ {子}

重定向比 mydom.com 之外的任何域 mydom.com

redirect any domain other than mydom.com to mydom.com

和则标准字preSS的htaccess

and then the standard wordpress htaccess

其从子部分做工精细外,所有子域被重定向回主域名(mydom.com)

Its working fine apart from the subdomain part, all subdomains are being redirected back to the main domain (mydom.com)

推荐答案

有这样的:

DirectoryIndex index.php

RewriteEngine On
RewriteBase /

RewriteCond %{HTTP_HOST} ^[^.]+\.[^.]+$ [NC]
RewriteRule ^ http://www.mydom.com%{REQUEST_URI} [L,R=301,NE]

# redirect sub.dom2.com to sub.mydom.com
RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.(?!mydom\.)[^.]+\. [NC]
RewriteRule ^ http://%1.mydom.com%{REQUEST_URI} [L,NE,R=302]

RewriteCond %{HTTP_HOST} admin\.mydom\.com$ [NC]
RewriteRule !^admin/system/ admin/system%{REQUEST_URI} [L,NC]

RewriteCond %{HTTP_HOST} ^(?!www\.)([^.]+)\.mydom\.com$ [NC]
RewriteRule !^subdomains/ subdomains/%1%{REQUEST_URI} [L,NC]

RewriteRule ^(subdomains/|admin/|index\.php$) - [L,NC]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

这篇关于htaccess的将不重写子域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆