I am trying to redirect all from non-www to www. So example.com redirects to www.example.com
I enabled Rewrite Engine in Apache and added this to .htaccess:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$
RewriteRule ^(.*) http://www.example.com/$1 [R=301]
At first look everything worked perfectly. But when trying to use my website's log in form to view areas of the site accessible only to logged in users it just appears to refresh the page. Nothing happens.
I've been trying to fix this for quite a while and haven't found any similar problems. Any help is appreciated! Thanks.
Silly me. Somewhere I declared the website as a variable in the form of example.com. Changed it and it works now.
Related
I am looking to 301 an entire domain on https://www.olddomain.co.uk to a new domain on https://newdomain.com via .htaccess. Currently, the version I have will only work if you manually remove the www from the old link showing in Google SERP for the old domain listing - so it shows 'This site can’t be reached' when clicked. Removing the 'www' part of the URL and hitting return performs the redirect.
Current .htacess is:-
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ https://newdomain.com/$1 [R=301,L]
</IfModule>
And I've also tried:-
RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.co.uk [NC,OR]
RewriteCond %{HTTP_HOST} ^www.olddomain.co.uk [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301,NC]
Important to keep the SEO value form the old domain. Any assistance appreciated here.
Thanks in advance
Glennboy
Fixed in 2 parts:-
The DNS settings on the domain did not cover 'www' which was a simple error that would have stopped 'www' showing anyway.
Added a valid SSL Certificate to the old domain to ensure safe traversing of SSL - SSL
In short, the issue was not the .htaccess implementation which was perfectly valid and now working fine.
So, we printed some cards but the card accidentally has www.sub.domain.com/example but when to try to go there it says the site cannot be reached but If we try to go to sub.domain.com/example it works.
The main website is made in WordPress but the landing pages (subdomains) are made using Unbounce can this be fixed using .htaccess? if so then which .htaccess file and how can we fix this.
Thank you
You need to redirect your www to non-www. That can be done by adding this to your .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
Don't forget to change yourdomain with your domain.
I have a domain: soloENEGYBAR.ca which is properly redirecting to soloNUTRITION.ca as long as it's http://
This does NOT WORK for https:// and errors (I do not know why).
THE GOAL
Is there a way to make it so the sub folders for soloenergybar.com ALSO redirect to the home page for solonutrition.ca? As well as get this to work for http:// and https:// instead of just http://
For example, right now if I go to: soloenergybar.ca/en/home it redirects to solonutrition.ca/en/home which doesn't exist!
I would like to know if there's a way to force EVERY URL combo from soloenergybar.ca to go to the home page of solonutrition.ca vs adding the additional folder tree info /en/home/?
Thank you!
Current HTACCESS setting:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^132\.148\.131\.136
RewriteRule (.*) "https://www.solonutrition\.ca\/$1" [R=301,L]
You may use this rule in your site root .htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} soloenergybar\.ca$ [NC]
RewriteRule ^ https://www.solonutrition.ca/? [R=301,L]
Make sure to clear your browser cache or test in a new browser to avoid old cache,
I got two domains. Lets say dom.com and dom.net.
Now I got alias on dom.net to dom.com, so when I come to dom.net it shows me dom.com - this is set on admin's webpage.
But I need when somebody comes from dom.net redirect him to dom.com/test/example.html.
My .htacces file is blank now.
Is it possible to do this using .htacces and how can it be done?
I got it!
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} dom.net$
RewriteRule ^(.*)$ http://www.dom.com/test$1 [R=301,L]
this code redirect me to test folder but still don't know how to redirect to .html page
I have my website in a subdomain:
subdomain.mydomain.co.uk
Now, I don't want to move subdomain.mydomain.co.uk but I want to use .htaccess to set it so that when someone types: mydomain.co.uk the url still remains mydomain.co.uk but acually shows subdomain.mydomain.co.uk
How can I do this?
Try putting this:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomain.co.uk [NC,OR]
RewriteRule ^(.*)$ http://subdomain.mydomain.co.uk/$1 [L,R=302,NC]
You could try doing an R=301, but beware of the dangers of using a 301 redirect. We had huge problems with our website at one point using 301 redirects as written about in this article: http://getluky.net/2010/12/14/301-redirects-cannot-be-undon/