简体   繁体   English

将子域重定向到新的URL

[英]Redirect a subdomain to a new URL

I have a client that had a main site in Joomla and a blog in WordPress. 我有一个客户,该客户在Joomla中有一个主要站点,在WordPress中有一个博客。 We just made everything one WordPress site. 我们只是将所有内容都制作成了一个WordPress网站。

What I need help with is redirecting the subdomain (eg blog.example.org) to the new URL (example.org/blog). 我需要帮助的是将子域(例如blog.example.org)重定向到新的URL(example.org/blog)。

I believe this needs to get done with .htaccess and it needs to be integrated with the WordPress stuff, too. 我相信这需要使用.htaccess来完成,并且也需要与WordPress集成。

Here's where I got so far: 这是我到目前为止所到之处:

# 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 

But it's not working. 但这不起作用。 Any thoughts and help are greatly appreciated. 任何想法和帮助,我们将不胜感激。

You just need to change the order: 您只需要更改顺序:

# 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

Try this: 尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM