I have created one sub-domain. It is also accessed via folder.
For example,
subdomain.website.com
which is also accessed in the following url
website.com/subdomain
How do i stop this? I think it can be done with htaccess. I am not sure.
In the htaccess file in website.com's document root, add these rules:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^subdomain.website.com$ [NC]
RewriteRule ^subdomain/?(.*)$ http://subdomain.website.com/$1 [L,R=301]
add following line in the .htaccess in your root directory:
RewriteEngine on
RewriteCond %{HTTP_HOST} !^subdomain\.domain\.com$ [NC]
RewriteRule ^/(.*)$ http://subdomain.domain.com/$1 [L,R=301]
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
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
I am trying to redirect all calls to mysite.com/api/foo/bar/json?param1=1... to mysite.com/api
I've tried
RewriteEngine On
RewriteRule "^api/?(.*)" "/api" [R=302]
But it doesn't work because it redirects in a loop
You need to exclude the destination path you are redirecting to
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/api/?$
RewriteRule ^api/?(.*) /api [R=302]
First check file permission maybe you don't have to made edit on the .htaccess file. Then insert this line of code.
RewriteEngine on
RewriteRule ^(.*)$ http://www.example.com/$1 [R=permanent,L]
I want to change the url 'http://www.xxxx.com/en/index.php/publisher/dashboardadvtsr' to 'advertiser.xxxx.com/dashboard'.How to use htacess rewrite method for this?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^xxxx.com/dashboard
RewriteRule ^(.*) http://www.xxxx.com/en/index.php/publisher/dashboardadvtsr
I tried this code in htacess, but it didn't work.Anybody please help me with a suitable solution.
You can use this rule as very first rule in root .htaccess of advertiser site:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^advertiser\.(xxxx\.com)$ [NC]
RewriteRule ^dashboard/?$ http://www.%1/en/index.php/publisher/dashboardadvtsr [L,NC,R=301]
I guess it's something like this instead...
RewriteEngine On
RewriteCond $1 ^dashboard$
RewriteRule ^(.*) http://www.example.com/en/index.php/publisher/dashboardadvtsr [L,R=301]
I'm not sure why you need to match HTTP_HOST if you're writing this in .htaccess file (which already resolves virtual host to the corresponding DocumentRoot folder)
Exist a way in Htaccess to say If HTTP_HOST = my.subdomain.com Then block access (403) for the files .php and .html?
I want that the only files accessible throug my subdomain are Images.
Try:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^my\.subdomain\.com$ [NC]
RewriteRule ^(.*)\.(php|html)$ - [L,F]
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^my\.subdomain\.com$
RewriteRule \.(php|html)$ - [NC,F]