简体   繁体   English

301子域重定向到文件夹

[英]301 subdomain redirect to folder

I'm forced to install wordpress on a subdomain (http://lnx.domain.tld), since www points to a windows server where there are other web apps that I need not to touch. 我被迫在子域(http://lnx.domain.tld)上安装wordpress,因为www指向Windows服务器,那里有我不需要接触的其他Web应用程序。

What I wish would be a clean, seo oriented way to rewrite the url so that it appears in a subfolder http://www.domain.tld/newsite . 我希望以一种干净,面向seo的方式重写URL,以使其出现在子文件夹http://www.domain.tld/newsite中

Any suggestion/example? 有什么建议/例子吗?

EDIT: it's just not possible to run wordpress from www 编辑:根本不可能从www运行wordpress

This is possible IF you can put a load balancer on top of your WordPress and IIS servers. 如果可以在WordPress和IIS服务器上放置负载平衡器,则可以这样做。 You can assign your domain to it and configure it to route requests based on the URL pattern. 您可以为其分配域,并将其配置为根据URL模式路由请求。 It still depends on how flexible your hosting provider is---the load balancer needs to be able to "see" the other 2 on the network to send/route the requests. 它仍然取决于托管服务提供商的灵活性—负载平衡器需要能够“看到”网络上的其他两个发送/路由请求。

My answer is based on experience as I had exactly the same requirements as yours. 我的答案基于经验,因为我对您的要求完全相同。 I am serving a blog and an IIS website under the same domain. 我在同一个域下提供博客和IIS网站。 I have a load balancer (HAProxy) on top of my IIS and WordPress machines. 我在IIS和WordPress计算机上有一个负载平衡器(HAProxy)。 It is configured to route requests to different servers based on the URL pattern. 它被配置为根据URL模式将请求路由到其他服务器。

Example: 例:

  • www.website.com/blog -> Wordpress server www.website.com/blog-> WordPress服务器
  • www.website.com -> IIS server. www.website.com-> IIS服务器。 (everything else / default server) (其他所有内容/默认服务器)

In config, it should look something like this: 在配置中,它应该看起来像这样:

# Frontends
frontend www
bind            xx.xx.xx.xx:xx
mode            http
option          httpclose
    default_backend iis_webserver

    # this is the condition
    acl blog-request path_beg -i /blog

    # route to a different machine if it's a blog
    use_backend blog_webserver if blog-request


# Backends: These are the machines that can accept requests.
backend iis_webserver
    ...settings...
    server server1 xx.xx.xx.xx:xx check
    server serverN xx.xx.xx.xx:xx check # (if you have more than one server)

backend blog_webserver 
    ...settings...
    server server1 xx.xx.xx.xx:xx check
    server serverN xx.xx.xx.xx:xx check # (if you have more than one server)

You can just put your wordpress root fold at your host wwwroot/ . 您只需将wordpress root foldhost wwwroot/
Then login your admin panel(visit: http://www.domain.tld/newsite/wp-login.php ), in your config area, set the wordpress URL to http://www.domain.tld/newsite and set the site URL to http://www.domain.tld/newsite , too. 然后登录您的管理面板(访问: http://www.domain.tld/newsite/wp-login.php ),在您的配置区域中,将wordpress URL设置为http://www.domain.tld/newsite并进行设置也是http://www.domain.tld/newsite的网站URL。

@ Francesco, I think I need to clarify that your new "URL" is a sub-directory. @ Francesco,我想我需要澄清一下您的新“ URL”是一个子目录。 @ Kjuly, in this case, Francesco doesn't actually need to move his blog folder. @ Kjuly,在这种情况下,Francesco实际上不需要移动他的博客文件夹。 He asks for a SEO friendly way to rewrite URL. 他要求SEO友好的方式来重写URL。 So the first thing comes into my mind is .htaccess 301 direction. 因此,我首先想到的是.htaccess 301方向。

eg 例如

RewriteEngine On
Options +FollowSymLinks
#test sub domain
RewriteCond %{SERVER_NAME} ^(www.)?subdomain.mydomain.com [NC]  
#avoiding repetitive redirection  
RewriteCond %{REQUEST_URI} !^/subdomain/ [NC]  
#redirect to subdirectory  
RewriteRule ^(.*)$ subdomain/$1 [L] 

Notice, if you use this method, you cannot create a directory with the name "subdomain" under //subdomain.mydomain.com/, or it can't be visit through this domain, as it's in use by someone else. 请注意,如果使用此方法,则不能在//subdomain.mydomain.com/下创建名称为“ subdomain”的目录,或者无法通过该域访问该目录,因为该目录已被其他人使用。

This could be another solution. 这可能是另一种解决方案。 Have you tried Wordpress for Windows ? 您是否尝试过Windows版Wordpress

If the size of your blog is not that big, you might want to consider installing that. 如果博客的大小不大,则可能需要考虑安装它。 Then import the content. 然后导入内容。

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

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