使用域目录中的.htaccess将子域重定向到域

编程入门 行业动态 更新时间:2024-10-22 05:15:20
本文介绍了使用域目录中的.htaccess将子域重定向到域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的网页以前是blog.example,但现在是example.我必须删除/blog目录(该网站位于blog.example所在的网站),因为我在URL example/blog上有一个Wordpress页面,因此将其搞砸了.

My webpage used to be blog.example, but it is now example. I had to delete the /blog directory (where the website hosted blog.example), because I have a Wordpress page at the URL example/blog and that screws it up.

我尝试过:

RewriteEngine on RewriteCond %{HTTP_HOST} ^blog\.example\ RewriteRule ^(.*)$ www\.example\/$1 [L]

以及:

RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?blog\.example\$ [NC] RewriteRule ^ www.example/%{REQUEST_URI} [NE,R=301,L]

并且:

RewriteEngine on RewriteCond %{HTTP_HOST} ^blog\.example\$ [NC] RewriteRule ^(.*)$ example/$1 [R=301,L]

但是,这些子域在子域中没有任何区别. 我该怎么做才能将blog.website/URLS重定向到website/URLS? (无需创建example/blog,因为它会破坏Wordpress的网页网站/blog)

But none of these make any difference in the subdomain. What can I do to redirect blog.website/URLS to website/URLS? (without creating example/blog because it will mess up Wordpress's webpage website/blog)

推荐答案

我知道了!我必须:

  • 从bluehost删除原本应该重定向的重定向 子域到主域
  • 在public_html/blog-redirect目录中创建子域blog.example
  • 将此重定向代码添加到/blog-redirect下的.htacces文件中:

  • Remove the redirect from bluehost that was supposed to redirect the subdomain to the main domain
  • Create the subdomain blog.example at the directory at public_html/blog-redirect
  • Add this redirect code to the .htacces file under /blog-redirect: RewriteEngine On RedirectMatch 301 ^/(.*)$ example/$1

  • 更多推荐

    使用域目录中的.htaccess将子域重定向到域

    本文发布于:2023-10-31 16:24:09,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1546623.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:重定向   目录中   htaccess   将子域

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!