Redirecting Subdirectory to Subdomain with htaccess

后端 未结 5 1575
再見小時候
再見小時候 2021-01-06 09:38

I\'m relatively new to using .htaccess, and have never done any coding besides what I\'ve read online. I\'m using Bluehost, and I\'d like to redirect my blog subdirectory t

5条回答
  •  梦谈多话
    2021-01-06 09:54

    I wanted to add my two cents,

    1) to answer the question above, this rewrite should fix it:

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !\.
    RewriteRule ^/blog$ http://blog.example.com [R=302,L]
    

    2) but, I think this is not enough by itself, you also need to change DNS, so that blog.example.com is pointed at the right server, and this can be done by a cname similar to this:

    blog.example.com  CNAME example.com TTL 1080
    

    (not exactly how it will look, but use your DNS webinterface to set this up).

提交回复
热议问题