I've ran a website I've made through SiteCheckerPro. I'm seeing a 'critical error', but I'm not sure how to fix it. The error is 'URL Vulnerability: Configured wrong'
The report says:
"URL Vulnerability
Search engines see your https://website.co.uk and
https://website.co.uk/index.html (or https://website.co.uk/index.php)
as different pages.
If you don't explicitly tell Google which URL is canonical, Google
will make the choice for you, or might consider them both of equal
weight, which might lead to unwanted behavior."
I understand what it's telling me, I just can't figure out how to fix it.
I've added a canonical tag
<link rel="canonical" href="https://website.co.uk/" />
and I've added a few htaccess rules to redirect www to non-www and http to https
#www > non-www
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
#http > https
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
I can't figure out what else I can do to fix this error?
Adding this to the htaccess file fixed the issue.
Redirect 301 /index.html https://website.co.uk/
Redirect 301 /index.php https://website.co.uk/
The error is no longer shows in the report.
Put this in your htaccess,
it Will redirect index.html or index.php
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ http://www.example.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^.*/index.html
RewriteRule ^(.*)index.html$ http://www.example.com/$1 [R=301,L]
RewriteBase /
RewriteCond %{HTTP_HOST} !=""
RewriteRule ^index.php(/.*)?$ http://%{HTTP_HOST}$1 [R=301]
Related
I'm rewriting a website with a larger google cache.
So my Problem is that the old links should be reachable but under a new URL.
I'm sitting since 8h to rewrite the URLs with htaccess... But it seems to be to hard for me, so how can I make this:
old htaccess:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
RewriteRule ^(.*) https://example.com%{REQUEST_URI} [L,R=301]
RewriteRule ^banana/(.*).htm$ https://example.com/banana/index.php?id=$1 [R=301,L]
Future config wish:
1. https://example.com/banana/Berlin.htm
2. https://example.com/banana/index.php?id=Berlin
both leading to --> https://example.com/banana.php?id=Berlin
working .htaccess for rewrite 1:
RewriteCond %{REQUEST_URI} ^/banana [NC]
RewriteRule /(.*) https://example.com/banana.php?id=$1 [R=301,L]
working .htaccess for rewrite 2:
RewriteRule ^(.*) https://example.com%{REQUEST_URI} [L,R=301]
RewriteRule ^banana/(.*).htm$ https://example.com/banana.php?id=$1 [R=301,L]
But either I run into Too many redirects or to not working rewrites...
And when i got one config working fine the oder old URL is pointing to 404 ...
Thank you in advance and very much!
I have a website, let's say www.example.com but this used to be www.example.nl. All traffic from www.example.nl is now redirected to www.example.com, but as we changed some naming conventions, www.example.nl/seeds now has to redirect to www.example.com/nl/flower-seeds.
The .htaccess file I got contains the following code:
RewriteEngine On
RewriteBase
RewriteCond %{HTTP_HOST} !example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L, R=301]
Redirect 301 /seeds/(.*) example.com/nl/flower-seeds/$1
When I navigate to www.example.nl/seeds/ I end up at www.example.com/seeds/ which ends up in a 404 because I'm missing the /nl/flower- part.
I think Redirect doesn't work properly when the URL is already altered by a RewriteRule. How would you tackle this problem? Any help is appreciated!
You should exclude /seeds/ directory form general rules like this :
RewriteEngine On
RewriteCond %{HTTP_HOST} !example.com$ [NC]
RewriteCond %{REQUEST_URI} !/seeds/(.*)
RewriteRule ^(.*)$ http://www.example.com/$1 [L, R=301]
RewriteCond %{HTTP_HOST} !example.com$ [NC]
RewriteRule ^seeds/(.*)$ http://www.example.com/nl/flower-seeds/$1 [L, R=301]
Note: clear browser cache then test
Also , don't use regex with redirect like what you did :
Redirect 301 /seeds/(.*) example.com/nl/flower-seeds/$1
Here this (.*) has no meaning , you could use either RedirectMatch or RewriteRule
I've used the 'Redirect mapper' tool by Varvy.com, and it's highlighted an issue with my www redirect. I'd like there to be only one redirect, but the tool shows two redirects. See screenshot below.
This is what I'm using in my htaccess file
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
As the screenshot shows, http://www.d3creative.uk 302 redirects to https://www.d3creative.uk/, then 301 redirects to https://d3creative.uk/
I'd like to http://www.d3creative.uk/ to 301 redirect to https://d3creative.uk/, skipping the www redirect.
Any help would be much appreciated!
UPDATE
I use ServerPilot to manage my server, and I've setup SSL using ServerPilot.
I've removed the original RewriteCond and RewriteRule lines from my htaccess file
This clears up the multiple redirects (see screenshot below), but I still need a way to redirect www to non-www
I've contacted ServerPilot support, I'll post back here with any answers.
Fixed!
Within the ServerPilot control panel there is an option to force a HTTPS redirect. This was conflicting with any redirects I was using in my htaccess file.
Turn 'Redirect to HTTPS' off and use the ruleset below in your htaccess
ServerPilot support kindly provided this ruleset, which works great.
RewriteCond %{HTTP_HOST} ^(www\.)(.*) [NC]
RewriteRule (.*) https://%2%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
All versions of my domain now redirect (once) to my preferred version of the domain.
I (sometimes) somehow manage .htaccess file successfully but need help on this one.
I'd like to achieve the following at the same time
Redirect anything non-www to www
Redirect anything with /site or /site/ to root
Redirect anything http to https
In the end, every link, no matter how it originated, should begin with https://www.domain.com/ and end with /original_request_directory_or_file_if_any
I can get #1, no problem
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^/?$ "http\:\/\/www\.domain\.com\/" [R=301,L]
I can get #2 no problem and it works together with #1
RedirectMatch 301 ^/site/$ http://www.domain.com/
What I am unable to achieve so far is #3
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
When I enable the above code, I get browser error for redirect loop errors.
Looking forward to a solution (because I am sure it's possible and I just don't know how.)
Thank you all in advance!
If you redirect all to https, avoid to redirect before to http.
RewriteEngine on
RewriteRule ^site/? https://www.domain.com/ [R=302,L]
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^domain.com$
RewriteRule ^ https://www.domain.com%{REQUEST_URI} [R=302,L]
Change [R=302,L] to [R=301,L] when everything works well
My client has a godaddy Virtual Dedicated Server (yes I know it sucks).... It has WHM VPS Optimized running on it .
I am trying to remove the index.php from the urls but my server still displays 404 errors I have looked at every forum in the universe and cant get an htaccess file that works. Here is what expression engine tells you to put use...
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} !^(/index\.php|/img|/js|/css|/robots\.txt|/favicon\.ico)
RewriteRule ^(.*)$ /index.php/$1 [L]
</IfModule>
I know diddly about Apache.. please help kind sirs...
Test if the htaccess is working:
# Redirect domain
RewriteCond %{HTTP_HOST} ^www.yourdomain.com$
RewriteRule ^/?$ "http\:\/\/google\.com" [R=301,L]
Or
# Remove the www from the URL
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
Ensure you actually have content appearing when you enter /index.php :P
Once you know your htaccess is working try "$1" instead of "%{REQUEST_URI}":
RewriteEngine on
RewriteCond $1 !^(img|admin\.php|themes|robots\.txt|index\.php|sitemap\.xml|/favicon\.ico) [NC]
RewriteRule ^(.*)$ /index.php?/$1 [L]
Also try "/index.php?/$1" instead of "/index.php/$1"
Ensure you have set EE (Admin->General Configuration) so "Name of your site's index page" is blank.
Remember that once you do get EE to work without the index.php appearing, it can be used both ways (with and without), which is bad for SEO, so remove it like so (place before the above rewrite :)
# Redirect index.php Requests (prevent site showing index.php in browser address bar)
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L]