Here is the link of subfolder
https://example.com/abc/ i want to add www to subfolders also like this https://www.example.com/abc/
To force WWW, simply use:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Related
I need to redirect all pages under a specific folder to another domain with different sub folders
For example:
FROM: https://www.my.domain.com/user/myuser/test.png
TO: https://www.newdomain.com/all/allegato1.png
I have try many htaccess file but all not work
RewriteEngine On
RewriteCond %{HTTP_HOST} ^my.domain.com$ [OR]
RewriteCond %{HTTP_HOST} www.my.domain.com$
RewriteRule ^user/myuser/(.*) http://www.newdomain.com/all/$1 [R=301,L]
I insert my .htaccess into the dir my.domain.com/user/myuser/
How can i made this rule? Thanks for your help
Inside /user/myuser/.htaccess following rule should work:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(?:www\.)?my\.domain\.com$ [NC]
RewriteRule .* http://www.newdomain.com/all/$0 [R=301,L]
I have a domain "example.com" and i use following redirection code to redirect it to www in .htaccess file
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
it is working fine until i generate a sub-domain with that domain like "abc.example.com" but it's getting conflicts with htaccess and redirecting the sub-domain to "www.abc.example.com/abc/"
You can use:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www|abc)\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
I want to redirect all pages (except for the home page) from one domain to another.
How do I do this?
This is the rule you have to add to your htaccess file.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
#if not root
RewriteCond %{REQUEST_URI} !^/?$ [NC]
#redirect
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
I want this:
domain.tld to www.domain.tld
And other subdomains: sub.domain.tld without redirect to www.sub.domain.tld
You can put this code in your htaccess (in root folder)
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain\.tld$ [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
I have this application directory
http://www.example.com/application
When user browse without www, (e.g. example.com/application), i want to force and redirect them to http://www.example.com/application
How can i achieve using .htaccess.
Thank you.
To redirect non www to www:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
To redirect www to non www, the code is similar:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^my-domain\.com$ [NC]
RewriteRule ^(.*)$ http://my-domain.com/$1 [R=301,L]