【问题标题】:.htaccess poiting a domain to another domain/directory.htaccess 将域指向另一个域/目录
【发布时间】:2013-08-10 03:08:35
【问题描述】:

我需要修改 .htaccess 文件,以便我可以覆盖我的域。 首先我告诉你,我对 .htaccess 文件一无所知。 而且那个 .htaccess 文件里已经有很多东西了。

我想要的是重定向我的

www.one-domain.com

www.second-domain.com/abc

我不想改变其他任何事情。只有 one-domain.com 开始显示 second-domain.com/abc 的内容

两个站点之间的域都是wordpress。

one-domain.com 内容位于 root/ second-domain.com 内容位于root/direcoty

下面是我已有的 .htaccess 文件的内容。

# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# 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
# 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
# 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
# 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
# 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

【问题讨论】:

  • 也只是www.onedomain.comwww.second-domain.com/abcwww.onedomain.com/foowww.second-domain.com/abc/foo?这将是一个外部重定向,并且还会更改浏览器中的 URL,可以吗?
  • 仅 www.onedomain.com 到 www.second-domain.com/abc。但是我不想要外部重定向,但这仍然可以,并且对我有用。

标签: apache .htaccess dns


【解决方案1】:

RewriteBase 行下方插入此代码:

RewriteCond %{HTTP_HOST} ^(www\.)?one-domain\.com$ [NC]
RewriteRule ^$ http://www.second-domain.com/abc [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>

你只需要在你的 .htaccess 中有这个块一次

【讨论】:

    猜你喜欢
    • 2011-08-05
    • 2013-12-29
    • 2014-09-11
    • 2020-05-04
    • 2011-05-31
    • 2014-02-25
    • 1970-01-01
    • 1970-01-01
    • 2012-09-19
    相关资源
    最近更新 更多