Thanks for the time. I'll preface by saying I'm not an expert coder by any means but I'll be happy to provide any info as needed.
I'm having a problem that's been going on the past two months thanks to a 301 redirect that I just can't seem to revolve. I help run a news site through WordPress and I had put in years ago a 301 redirect for all HTTPS links to become HTTP after getting complaints about a newsletter plugin rendering links in HTTPS and scaring off readers with warning labels. Little did I know about Google's upcoming shift to HTTPS for Chrome users at the time...
The short version of the story I basically put in a 301 into .htaccess that I can't seem to get rid of now that I converted everything to HTTPS. I followed all of the necessarily instructions and removed the old HTTPS-to-HTTP 301 in the .htaccess file back in September. Yet, months later the old redirect still remains on some of the pages. I can't force all pages to HTTPS since on some pages it creates a redirect loop. The same goes for parts of my sitemap. Therefore, every now and then browsing the site I still have old pages being served via HTTP. I'll attach the code for the .htaccess so you can at least see what's going on there. (I'm excluding the W3TC part to keep it from getting too cumbersome.)
Thanks for any and all suggestions!
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Related
I have the following issue and can't find a solution. Also I am not sure if this does work at all.
I have two domains. domain.de and domain.com
The german site has the domain domain.de. As soon as the domain domain.com is being used the redirect shall be to domain.com/en/. In other words. Only if the domain.com is used it shall be redirected to domain.com/en/.
But at the same time there are other URLs. e.g. domain.com/en/about-us/ .. or domain.com/it/bieno/. They all should not be affected.
Is it possible to redirect only the domain domain.com to domain.com/en/ and at the same time all other URLs would still be working?
It is a TYPO3 9.x installation btw. Perhaps I can solve this in TYPO3?
Eric
If you're using Apache (or a different webserver which supports this) you can use mod_rewrite to achieve this by adding the following to your .htaccess (replacing the domains of course):
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC]
Rewriterule ^/?$ https://example.com/en/ [L,R=301]
The RewriteCond checks if the domain is example.com or www.example.com. If you only need it to work for example.com, you can remove (www\.)?. ^/?$ checks if the requested path is / or empty.
If you use the default .htaccess for TYPO3, you don't need RewriteEngine On, but you will need to add this somewhere after the existing RewriteEngine On and before RewriteRule ^.*$ %{ENV:CWD}index.php [QSA,L]. I'd add it right after RewriteEngine On.
Years ago, someone setup a subdomain or alias on our site and some pages, but we've had some problems clearing them out and need all old, broken references redirected to our home page.
While our site is "example.com" the subdomain is "www2.example.com" even though we can't find "www2" listed on the host cpanel subdomains, not in the .htaccess, alias etc. I did find a CNAME record and redirected it to to our home page (example.com).
However, there are lingering pages, such as www2.example.com/page1 that get redirected to example.com/page1 and a 404 error instead of going to the home page at example.com.
So I added this to the .htaccess file, but it does not seem to be working:
# www2 redirect
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www2.example\.com$ [NC]
RewriteRule ^(.*)$ http://example.com [R=301,L]
</IfModule>
Thoughts?
Based on the standard cPanel setup, each sub-domain will have its own folder at main public directory("/public_html/www2"). So, you need to redirect every file from that sub domain/folder to main domain/folder.
Your final .htaccess file would be this simple config:
//301 Redirect Entire Directory
RedirectMatch 301 /www2(.*) //$1
Hope it helps!
Hi im hosting my site in bluehost, I have a problem with http to https redirect. I tried to create a redirect in htaccess and I get a redirect loop. When I remove my htaccess redirect and tried to put https://mysite.com I think it redirects me to http. But I can't seem to find where did that redirect happens, is it possible that it is because of dns record?
UPDATE:
also how can I put the padlock instead of the blank white paper in the browser url.
Try the following:
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# Here, we set all visiting browsers to WWW.domainname.ext
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Good luck! I hope this solves your problem.
If there is an A-record on www.yourdomain.com, it will overrule your HTACCESS.
I ran a duplicate checker for my website and got the following message
WWW/NonWWW Header Check: FAILED Your site is not returning a 301
redirect from www to non-www or vice versa. This means that Google may
cache both versions of your site, causing sitewide duplicate content
penalties.
Is this something that i should be worried about and if so how should i fix it ?
You shouldn't be worried about it, allot of sites are configured that way and google knows that.
However you can still add this if you want to be safe and send your visitors and google always go to example.com instead of www.example.com
Add this to your .htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
i made a grave mistake with my site. i didn't check the difference between .www and non .www so the one that had the www in it was a little broken.
well anyways i've plugged a 301 redirect in here, and for http://mysite.com it's fine as usual, but the http://www.mysite.com now adds on /index.php. that can't be the best for SEO, right? (the cms is Textpattern if that is relevant)
another problem this redirect code has is: http://www.mysite.com/blog will take you back to the homepage.
what do you think?
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mysite.com$ [NC]
RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L]
i seem to have found the problem. i think that 301 script has to be at the top of the .htaccess document or it will cause problems. such as the blog problem and the /index.php inconsistency.