skip to Main Content

I’m looking for a special redirect system (htaccess) for improving SEO and the indexed structure of a website in google.

There are some Domains, who pointing to Website root directory. Therefore the Websites gets delivered by multiple Domains.

Specification for the Redirect System:

  • http -> https
  • www -> non-www
  • redirect to one host
  • only one 301 redirect (no several redirect behind each others)

Example:

Main Domain: domain-a.com

Goal: https://domain-a.com/XXX

Please look as this example Set

>>> Redirect Examples

2

Answers


  1. Did you try just google same answers like this or this?

    Try this:

    RewriteEngine On
      RewriteBase /
    
      RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
      RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
    
    Login or Signup to reply.
  2. RewriteEngine on
    
    # other domains
    RewriteCond %{HTTP_HOST} !^domain-a.com [NC]
    RewriteRule .* https://domain-a.com%{REQUEST_URI} [R=301,L]
    
    # Redirect to domain with HTTPS.
    RewriteCond %{HTTPS} off
    RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
    
    # Same for www:
    RewriteCond %{HTTP_HOST} ^www. [NC]
    RewriteRule .* https://domain-a.com%{REQUEST_URI} [R=301,L]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search