Changing the Root Folder via .Htaccess

Changing the root folder via .htaccess

If I'm understanding correctly, the following should work

RewriteEngine On

RewriteCond %{REQUEST_URI} !^/public/
RewriteRule ^(.*)$ /public/$1 [L,R=301]

This will redirect all requests that do not begin with /public/ to URL that does.

Hope that helps.

Change root directory in .htaccess

You need to use a dynmic pattern :

RewriteEngine On
RewriteBase /comparty/
#if the request is not for an existent dir
RewriteCond %{REQUEST_FILENAME} !-d
#and the request is not for an existent file
RewriteCond %{REQUEST_FILENAME} !-f
#rewrite the request to "/pages/request"
RewriteRule ^(.*)$ pages/$1 [L]

RewriteConditions above are important to avoid rewriting your existent files and directories to the /pages subfolder. Without those conditionrt the Rule will rewrite all requests including the destination path /pages and this may result in rewrite loop error.

htaccess Change the root folder for one of my domain

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.)

HTACCESS - Setting root folder as public_html

The following .htaccess code can be added to achieve the results wanted:

RewriteEngine on

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


Related Topics



Leave a reply



Submit