How to setup a redirection from root domain name to a sub folder?

Maxoq

Well-known member
Registered
Joined
Feb 25, 2015
Messages
520
Points
28
Hi there,

How can I setup a redirection from root domain name to a sub folder?

For example:
when a visitor enter my website at example.com it will be redirected to example.com/blog/

At this time, I have not got a homepage hence I would like to run a blog first, and it will currectly use as homepage of my website. When I have a homepage, I can remove this redirection and run homepage and blog as separated pages.

Thanks
 

VirtuBox

Well-known member
Registered
Joined
May 3, 2016
Messages
1,622
Points
83
Hello,
with Plesk, you can set the following code in Apache & Nginx settings > Additional Nginx directives

NGINX:
location =/ {
    return 302 https://$host/blog/;
}
You can also use a 301 redirection instead of the 302 in my example, but if it's a temporary redirection, I think a 302 is enough.
 

HostechSupport

Active member
Registered
Joined
Jan 19, 2013
Messages
68
Points
8
hello Maxoq, you can use this code in .htaccess file for redirection:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^$ http://example.com/blog/ [L,R=301]
 

Veesp

Member
Registered
Joined
Apr 18, 2017
Messages
47
Points
8
Hi, @Maxoq!
301 HTTP-status means that your website is permanently moved from the requested URL to a new one while the web page weight of the old page is transferred to the new one.
Redirect 302 does not convey the page weight of the donor to the acceptor. It is better to use 303 and 307 redirects for temporary redirection. This is due to incorrect processing of the status 302 in some browsers.
You can set up a temporary redirect using Apache or Nginx.
You can do it manually or using some online tools which you can use to generate htaccess rules, for example, https://www.aleydasolis.com/htaccess-redirects-generator/.
Also, you can convert Apache's to nginx configuration with https://winginx.com/en/htaccess if it is needed. HTH
 
Latest Threads
Replies
1
Views
27
Replies
0
Views
190
Replies
1
Views
40
Replies
2
Views
83

Latest postsNew threads

Latest Hosting OffersNew Reviews

Sponsors

Tag Cloud

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top