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
PHP Variable Interpolation VS Concatenation
Error 403 in Loading Resources Like CSS and Js in My Index.Php
When *Not* to Use Prepared Statements
How to Display Unicode Data with PHP
Counting Occurrence of Specific Value in an Array with PHP
Converting HTML to PDF (Not PDF to HTML) Using PHP
Algorithms for String Similarities (Better Than Levenshtein, and Similar_Text)? PHP, Js
Get Value of Dynamically Chosen Class Constant in PHP
How to Convert Word Smart Quotes and Em Dashes in a String
How to Create Installer for Website. PHP MySQL
Codeigniter - Using Multiple Databases
PHP "Pretty Print" HTML (Not Tidy)
HTML Upload Max_File_Size Does Not Appear to Work
PHP Cli: How to Read a Single Character of Input from the Tty (Without Waiting for the Enter Key)
Replace Woocommerce_Add_Order_Item_Meta Hook in Woocommerce 3.4