将子域重定向到新网址

时间:2017-10-02 17:06:23

标签: wordpress .htaccess redirect subdomain

我有一个客户端,在Joomla中有一个主站点,在WordPress中有一个博客。我们刚刚制作了一个WordPress网站。

我需要帮助的是将子域名(例如blog.example.org)重定向到新的URL(example.org/blog)。

我认为这需要完成.htaccess,它也需要与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]
RewriteCond %{HTTP_HOST} ^example.health-access.org
RewriteRule ^(.*)$ http://example.org/blog/$1 [L,NC,QSA]
</IfModule>
# END WordPress 

但它没有用。非常感谢任何想法和帮助。

2 个答案:

答案 0 :(得分:1)

您只需要更改顺序:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^example.health-access.org [NC]
RewriteRule ^(.*)$ http://example.org/blog/$1 [R=301,L,QSA]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
#END WordPress

答案 1 :(得分:0)

试试这个:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^yoursubdomain\.yourdomain\.com$ [
RewriteRule ^(.*) http://www.newdomain.com/?param=data&uparam2=data