简体   繁体   English

使用nginx和htaccess重写Wordpress子域

[英]rewrite Wordpress subdomain with nginx and htaccess

I got a domain ihakula.com, and I want to use blog.ihakula.com to point to my blog with wordpress. 我有一个域ihakula.com,我想使用blog.ihakula.com指向我的博客与wordpress。

And the path for wordpress is www.ihakula.com:9000/blog/, but I want in address bar which looks like no1.ihakula.com. wordpress的路径是www.ihakula.com:9000/blog/,但我想要的地址栏看起来像no1.ihakula.com。

Now I use Nginx and .htaccess to made it, seems I got problems. 现在我使用Nginx和.htaccess来制作它,似乎我遇到了问题。

Here is the Nginx code: 这是Nginx代码:

# For ihakula blog
    server {
        listen 80;
        server_name no1.ihakula.com;

        location / {
            proxy_pass http://www.ihakula.com:9000/blog/;
        }
    }

Here is the htaccess code: 这是htaccess代码:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.ihakula\.com\:9000\/blog\/$
RewriteRule ^/?$ "http\:\/\/no1\.ihakula\.com\/" [P,L]
</IfModule>

Now I removed .htaccess file and changed the wordpress general config looks like this: 现在我删除了.htaccess文件并更改了wordpress一般配置如下所示: 在此输入图像描述

I can reach my wordpress console start with no1.ihakula.com/wp-admin. 我可以通过no1.ihakula.com/wp-admin到达我的wordpress控制台。 But when I hover any Post, the link shows below still start with www.ihakula.com:9000 looks like below: 但是当我悬停任何帖子时,下面显示的链接仍然以www.ihakula.com:9000开头,如下所示: 在此输入图像描述

Any ideas? 有任何想法吗?

No, you do not need to do anything in your htaccess file. 不,您不需要在htaccess文件中执行任何操作。 NGINX proxy can handle the request URL change automatically. NGINX代理可以自动处理请求URL更改。 What you are doing is actually making the sites to undertake infinite redirects. 你正在做的是让网站进行无限重定向。

What you should do more is to set the BLOG URL in WordPress to no1.ihakula.com , so that WordPress scripts will automatically give the URLs begins with no1.ihakula.com . 你应该做的更多是将WordPress中的BLOG URL设置为no1.ihakula.com ,这样WordPress脚本将自动提供以no1.ihakula.com开头的URL。

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

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