I have to upload a directory by default when someone comes to my static website
this is the structure
under my public_html I have domain folder 'domainname'. In domain folder I've webfolder/fr/index.html
I want to load files under webfolder/fr directly. following is my .htaccess under the domain name
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domainname$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domainname$
RewriteCond %{REQUEST_URI} !webfolder/fr/
RewriteRule (.*) /en/$1 [L]
if I remove fr/index.html it loads files under webfolder. If I set
RewriteCond %{REQUEST_URI} !webfolder/fr/
it gives 500 internal error.
Please help me how can I fix this.
To Clarify:
When I open my domain www.domain.com I want it to open www.domain.com/webfolder/fr
Please add following two lines to allow a specific file to load just in case there is no default index file setup already
Options -Indexes
DirectoryIndex index.html index.php
Note : if you have to load first php index file then you have set like
DirectoryIndex index.php index.html
So you want to redirect your domain from root folder to some other subfolder
try this code
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domainname$ [NC,OR]
RewriteCond %{HTTP_HOST} ^domainname$
RewriteCond %{REQUEST_URI} ^/$
RewriteRule (.*) /webfolder/fr [L]
hope this code will work for you
optional:-you can also do this by changing your home directory in cpanel settings
Related
Currently I'm using this .htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.org$ [NC,OR]
RewriteCond %{HTTP_HOST} ^www.mydomain.org$
RewriteCond %{REQUEST_URI} !production/
RewriteRule (.*) /production/$1 [L]
so if i'm hit mydomain.org or mydomain.org/* it will pointing to public_html/production folder
But now i need exceptional rules to point mydomain.org/api to folder public_html/api.
How to achieve this?
just for your reference...
try this in your localhost. make one project folder then create one .htaccess file in your root directory
write below code in .htaccess file
RewriteEngine On
RewriteRule ^game/([0-9]+)? http://triviamaker.com [R=301,L]
now run this,
localhost/your_Project_Folder_Name/game/_any_number/ ... when you run this url you will automatically redirect to another url which is set in .access file
I hope you understand this thank you
My Folder Structure
Root Domain
assets/ (contains css, images, js folders)
subfolder/ (contains Codeigniter Project inside and seperate .htaccess)
index.php
contact.php
.htaccess
Root Htaccess
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !(.*)subfolder
RewriteRule ^(.*)$ subfolder/$1 [L]
Subfolder(Codeigniter Project) Htaccess
DirectoryIndex index.php index.html
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond $1 !^(index\.php|assets|install|update)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# For godady Shared Hosting Server uncomment the line below
RewriteRule ^(.*)$ index.php?/$1 [L]
</IfModule>
List of Subfolder URLs
http://example.com/subfolder/products/
http://example.com/subfolder/product/product-slug-123
List of Root URLs
http://example.com/index.php
http://example.com/contact.php
In my Codeigniter Project I've set Products controller as default_controller.
So the problem is, when I try to access the index.php page in the Root folder it only displays the Codeigniter products list as Home page.
I need following URLs:
http://example.com/index.php
http://example.com/contact.php
http://example.com/products/
http://example.com/product/product-slug-123
Any solutions with htaccess or with code?
Finally I got this working.
RewriteCond %{REQUEST_URI} !((.*)subfolder|^/assets) // to Exclude this
RewriteCond %{REQUEST_URI} (^/products(.*)|^/product(.*)) // to Include this
RewriteRule ^(.*)$ subfolder/$1 [L]
Exclamation(!) symbol used to 'not' matching urls.
So I removed Exclamation symbol and used another RewriteCond (Condition) to redirect only if the url contains segment as products or product http://example.com/products/ or http://example.com/product/product-slug-123. It's working perfectly now. I thought, sharing this would be useful to someone. Happy coding.
I am trying to point the main domain from my host (https://website.com) which right now just goes to public_html to a subfolder in the public_html directory (new.website.com) with the user still seeing https://website.com without changing.
I tried doing what is found in here: https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
And added this code to the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?website.com$
RewriteCond %{REQUEST_URI} !^/new.website.com/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /new.website.com/$1
RewriteCond %{HTTP_HOST} ^(www.)?website.com$
RewriteRule ^(/)?$ new.website.com/index.php [L]
However 2 things happened incorrectly:
The domain changed to https://new.website.com/404.html
It is giving me a page to proceed with caution since new.website.com does not have a certificate.
(folder name and also a subdomain are both named: new.website.com)
How can i redirect so it still shows https://website.com and go to the wordpress folder?
If I understand your question right, you need to have website.com visible to the public but actually, WordPress is installed on new.website.com
In this case, you need to do Wordpress multisite.
Check: https://codex.wordpress.org/Create_A_Network
I have an apache server for the system https://theveganhut.co.uk ; I need to have different sites in the same server. So, I put the files for http://theveganhut.co.uk in a folder theveganhut.co.uk in the public_html folder.
I have mapped the domain theveganhut.co.uk to the folder theveganhut.co.uk via the .htaccess file in the root(public_html)
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
</IfModule>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?theveganhut.co.uk$
RewriteCond %{REQUEST_URI} !^/theveganhut.co.uk/
# Don't change the following two lines.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /theveganhut.co.uk/$1
# Change example.com to be your main domain again.
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?theveganhut.co.uk$
RewriteRule ^(/)?$ /theveganhut.co.uk/ [L]
But when I load the url http://theveganhut.co.uk/admin , the admin login page is seen, but the URL changes to http://theveganhut.co.uk/theveganhut.co.uk/admin/. I want the url to be http://theveganhut.co.uk/admin/
Is there something I am missing in the .htaccess file to address this issue? Please help.
How to display contents from www directory for http://www.website.com
i..e when a user visits http://www.website.com i want to display the contents from /www directory but keep the url same.
I have tried few methods, but for all of them the url changes as well....
Though i want to load the content from http://www.website.com/www/ i want to keep the url as http://www.website.com/
And same for other pages., i..e http://www.website.com/products.php : /www/products.php
You can use an htaccess file
RewriteEngine on
# Only apply to website.com URLs outside the www folder, but ignore real files and folders
RewriteCond %{HTTP_HOST} ^(www.)?website.com$
RewriteCond %{REQUEST_URI} !^/www/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /www/$1
# Finally redirect the topmost folder itself
RewriteCond %{HTTP_HOST} ^(www.)?website.com$
RewriteRule ^(/)?$ www/index.php [L]
If you are running apache, you can change the root folder in the httpd.conf file (UserDir)
http://httpd.apache.org/docs/2.0/mod/mod_userdir.html#userdir
So you would have to do something like:
UserDir /www/