SOLVED How to host the Primary Domain from a subfolder without showing subfolder in browser url

AppleJukes

Registered
Aug 4, 2017
3
2
3
Malaysia
cPanel Access Level
Website Owner
Hi, I tried to look for solutions, but i couldn't get it. i hope anybody can help me to solve my issue.

i have a primary website domain : "example.com

i install wordpress inside the folder : main

the website can be access by visiting : "http://www.example.com/main/index.php

What i want to do is to remove the subfolder name from url, so when i access the link, it will show only "http://www.example.com/index.php" so the subfolder didn't appear in the url.

i tried this code bellow, but it still show the folder in the url browser.
# .htaccess main domain to subdirectory redirect
# Do not change this line.
RewriteEngine on

# Change example.com to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$

# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subdirectory/

# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Change 'subdirectory' to be the directory you will use for your main domain.
RewriteRule ^(.*)$ /subdirectory/$1

# Change example.com to be your main domain again.
# Change 'subdirectory' to be the directory you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ subdirectory/index.html [L]
Anybody can help me to resolve my problem? really appreciate your help :)
Thank you.
 

rpvw

Well-Known Member
Jul 18, 2013
1,101
465
113
UK
cPanel Access Level
Root Administrator
  • Like
Reactions: cPanelMichael

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,908
2,216
463
Hello,

You can follow the instructions under the "Moving Directories On Your Existing Server" section on the following WordPress document:

Moving WordPress « WordPress Codex

Let us know if that helps.

Thank you.