redirects – Using htaccess to force HTTPS does not work

There seems to be a lot of misinformation / confusion here …

The host who takes care of my SSL just told me "The SSL that we provide with your contract protects only one domain or subdomain, not both."

That should go, you seem to have only one area. However, your SSL certificate must cover both the top of the domain (that is to say. example.com) and the subdomain www (ie. www.example.com) – that should be enough – I would be very surprised that this is not the case. And by what you said at the beginning of the question; That done.

They then told them that it was for that bebechan.net/ebook has not been protected but bebechan.net was.

It's just about anything. The security certificate (SSL certificate) protects the host names and not the subdirectories. Yes example.com is protected then example.com/ebook is also protected, as it is example.com/.

But, bebechan.net/ebook a subdomain is not it true? It's still part of my domain bebechan.net?

Exactly.

I have just checked right now and it is written that SSL is provided for 'clickandbuild / bebechan & # 39; and I actually have a clickandbuild folder when I check my FTP … and there is already a .htaccess The. Maybe that's the problem? Maybe I should edit this one instead of creating a new one at the root?

It is possible that the root of the document is put in the directory /clickandbuild/bebechan, but as noted above, SSL certificates cover hostnames and not subdirectories.

For the rest of this answer, I'll assume that /clickandbuild/bebechan is actually the root directory of the document. that is to say. the directory that is served when you ask http://example.com/ (HTTP to HTTPS).

Your FTP screen capture is confusing / ambiguous. If there is a .htaccess drop in the /clickandbuild/bebechan subdirectory so presumably where WordPress is installed? However, your screen capture seems to show a .htaccess file and installation of WordPress in the root phone book?! I guess it's above the root of the document? So, what do these files correspond to?

… there is already a .htaccess The. Maybe that's the problem? Maybe I should edit this one instead of creating a new one at the root?

This could very well be the problem. You should not need to manually create the .htaccess file. WordPress will create (and use) a default – it is necessary to control the "pretty" permalinks of WordPress, which you already seem to use.

So yes, edit the existing .htaccess file. Do not create another .htaccess drop elsewhere.

The end of your existing /clickandbuild/bebechan/.htaccess file reads …

:


    RewriteEngine On
    RewriteBase /
    RewriteRule ^index.php$ - (L)
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php (L)


AddHandler x-mapp-php5.5  .php

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - (L)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php (L)


# END WordPress


RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.bebechan.net/$1 (R,L)

The main problem here is that HTTP to HTTPS redirection is in the wrong place! This should not be at the end of the configuration file like this. You have to go near the top of the .htaccess file – mostly he has to go before the front-end WordPress controller (ie the code block in the # BEGIN WordPress# END WordPress comment markers that precede it currently).

By placing the redirect at the end, as it appears here, it will be redirected example.com/ (the root of the document), but not example.com/smth – what is the behavior that you initially stated in your question. However, you also stated that www.example.com/smth IS is redirected – this can not explain this behavior.

Above .htaccess file, the WordPress front-end controller is also repeated unnecessarily – two blocks of code are identical – this is an error. The end of that .htaccess The file should read as follows:

:

AddHandler x-mapp-php5.5  .php

# HTTP to HTTPS redirect
RewriteCond %{SERVER_PORT} 80
RewriteRule (.*) https://www.bebechan.net/$1 (R=301,L)

# BEGIN WordPress

RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - (L)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php (L)


# END WordPress

About wordpress, I do not know how it is installed and I have not configured wordpress to do anything. Maybe I should?

Yes you should. Whether you use a plugin or manually … you need to make sure that the "WordPress Address (URL)" and "Site Address (URL)" options are set correctly (that is, https://www.example.com/). You may also need to define define('FORCE_SSL_ADMIN', true); in the wp-config.php file. There is more information about configuring WordPress elsewhere.

You do not want a tone .htaccess redirects to conflict with what WordPress thinks your canonical URL should be.

Do redirects affect Google Analytics?

I have a website that redirects as follows:

  1. https://example.com/drugs/paracetamol.html

  2. http://example.com/drugs/new-paracetamol.html – 302

  3. https://example.com/drugs/new-paracetamol.html – 302

I am aware that this is currently a problem and that the second redirection is not necessary, it is a bug in the redirection configuration. However, what interests me, would this configuration currently affect the results of Google Analytics in any way? If yes, would it affect?

Thank you

wordpress – WP Apache .htaccess redirects .com traffic to .co.uk

Since this is a WordPress site, you probably have other mod_rewrite guidelines in your .htaccess file to drive the WP "pretty" permalinks.

The behavior you are experiencing seems to be consistent with placing the redirect directives in the wrong place. This redirection must go before existing WordPress guidelines.

However, your condition is not strictly correct, provided you wish to canonize / redirect example.co.uk as well as? Your current RewriteCond directive is only satisfied if the requested host is not www.example.co.uk and not example.co.uk (since you made the www subdomain in negative state. the NC flag must also be omitted here to redirect misplaced queries for the canonical host name.

RewriteCond %{HTTP_HOST} !^www.example.co.uk$
RewriteRule (.*) https://www.example.co.uk/$1 (R=301,L)

# BEGIN WordPress
# ... WP directives follow...

Redirect something other than www.example.co.uk (exactly).

Htaccess redirects after URL language format change

After changing the language format of the URL of

http://my-site.com/name-of-page/?lang=en
http://my-site.com/name-of-page/?lang=ru

at

http://my-site.com/en/name-of-page/
http://my-site.com/ru/name-of-page/

I would like to redirect old versions of URLs to current versions.

I found this code snippet online and apparently, it partially solves my problem.


RewriteEngine on
RewriteCond %{QUERY_STRING} lang=en
# exclude all requests starting with /wp-admin/
RewriteCond %{REQUEST_URI} !^/wp-admin/.*$
RewriteRule ^(.*) /en/$1? (L,R=301)

However, it is designed to lang=en only!

How could I also include lang=ru in it for that it redirects at once lang=en and lang=ru?

Thank you in advance for any valuable hint!

Problems with the HostinFive website? Each link redirects to the home page

I am a customer of this provider who tries to perform various actions on his site, but whatever I click on my account, he is redirected to the home page.
I have tried this on several devices in the same direction.

Is someone else a customer who lives this?

For non-customers, do you know what would cause this problem for a website?

I contacted their direct assistance email, but I was wondering what I should do if I did not get a quick response.

Rearrange parts of the URL path to put the date together using .htaccess redirects

ancient permalink:

https://www.example.com/2019/cat/subcat/10/25/post-name/amp/

new permalink:

https://www.example.com/2019/10/25/cat/subcat/post-name/amp/

How can I redirect the old format to the new one with htaccess?

seo – 301 redirects ASP pages to HTML

I've therefore remodeled a site built solely from .asp pages and redone it with the help of .html pages. I've deleted the old site and downloaded the new one, then my .htaccess file with the following code "Redirect 301 /studio.asp /studio.html" etc. I was expecting that when I clicked on a Google entry, redirect the old page /studio.asp to /studio.html but that is not the case? What am I doing wrong? I should say that I have tried to keep the filenames and the old structure as much as possible identical when redesigning, but it still shows the old .asp pages. Or did I miss something entirely here? Does my old site still need to be active for redirects to work? Is it important that the old file extension is .asp? He is always sitting on the same URL.

htaccess redirects from the subdomain directory to the main domain

I need to redirect all requests from a subdomain-specific directory to the main domain.

Example:

dev.example.com/directory/test

need to redirect to

example.com/directory/test

(only redirects requests with directory directory)

How would you implement redirects for domain canonicalization, no-www and HTTPS for IIS 7.5?

Assuming you are using the URL rewrite module, you can use the following rewrite ruleset in web.config:


  
    
      
        
        
        
          
          
        
        
      
      
        
        
        
          
          
        
        
      
      
        
        
        
          
          
        
        
    
  

Orders can be important – the rules are processed from top to bottom and can "fail", so the following rules can also affect a request – in this case the type of action is Redirect, the stopProcessing directive is probably redundant.

Each of these rules will respect the original path, so a request for http://www.examplesite.com/folder/page1.aspx should end up on https://example.com/folder/page1.aspx.

To explain the rules:

  • ForceToExample.com
    This will redirect any request to examplesite.com or www.examplesite.com at https://example.com, whatever the schema of origin (http or https).
  • ForceFromWWW
    This will redirect any request (which has not been redirected) since www.example.com at https://www.example.com/whatever the original pattern.
  • ForceToSsl
    This will redirect any request (which has not been redirected) since http://example.com at https://example.com

I've deliberately left the element of redundancy in these rules, because I feel that it makes it easier to read and understand what each one is doing.

Expected behaviour:

  • http://www.examplesite.com/ correspond ForceToExample
  • https://www.examplesite.com/ correspond ForceToExample
  • http://examplesite.com/ correspond ForceToExample
  • https://examplesite.com/ correspond ForceToExample
  • http://www.example.com/ correspond ForceFromWww
  • https://www.example.com/ correspond ForceFromWww
  • http://example.com/ correspond ForceToSsl
  • https://example.com/ does not match any rule and will be processed by your application

Some additional points to note:

  1. If you moved the or elements of your web.config file, you will need to restart the application to see your changes in action.
  2. During the test, I prefer to use redirectType="Found" in action – a 302 redirect is issued and your browser does not cache the new request.