简体   繁体   中英

htaccess Change the root folder for one of my domain

htaccess Change the root folder for one of my domain.

My Current Url is Like This

domain.com/theme/

I want to like this

domain.com/

Please Share Your Valuable Answers...

By default, any website is loaded from the public_html folder. I'm assuming that you have a folder inside the public_html folder and your website's files are in that subfolder. If you do not want the subfolder to appear as a part of the URL to your website, you can mask the subfolder from the URL by placing the following directives in the .htaccess file inside the public_html folder:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain-name.com$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.domain-name.com$
RewriteCond %{REQUEST_URI} !folder/
RewriteRule (.*) /folder/$1 [L]

if You Can't Enter Your Domain Name then You Do Like This Include HTTPS -

RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_URI} ! folder/
RewriteRule (.*) /folder/$1 [L]

In the above lines you should replace the following:

domain-name.com - Type your domain name

folder - Type the name of the subfolder which has the website's files (in your case the name of the subfolder is theme.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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