Три последовательных 301 редиректа объединить в один

Помогите пожалуйста объединить 301 последовательных редиректы в один. Пытался сам, но чего то я не могу понять.

http://www.example.com/index.php?asd=asd -> https://example.com

Нужно :

  1. редирект с http на https
  2. редирект с www.example.com на example.com
  3. редирект с example.com/index.php на example.com/
  4. редирект с example.com/ на example.com ( но только на главной, на остальных случаях, в конце, слэш нужно оставить )

Нужно объединить в один.

Сейчас происходит три 301 редиректа :

  1. 301 http://www.example.com/index.php?asd=asd
  2. 301 http://example.com/index.php?asd=asd
  3. 301 http://example.com/?asd=asd
  4. 200 https://example.com/?asd=asd

Вот мой .htaccess :

Options -Indexes 
    ErrorDocument 404 /404.php
    
    <IfModule mod_php5.c>
        php_flag allow_call_time_pass_reference 1
        php_flag session.use_trans_sid off
    </IfModule>
    
    <IfModule mod_rewrite.c>
        Options +SymLinksIfOwnerMatch
        RewriteEngine On
    
        RewriteRule ^(.*)index\.php$ $1 [R=301,L]
        RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.(php|html|htm)\ HTTP/
    
        RewriteCond %{REQUEST_URI} /index.php
        RewriteRule ^(.*)$ https://example.com/ [R=301,L]
    
        RewriteCond %{REQUEST_URI} !\?
        RewriteCond %{REQUEST_URI} !\&
        RewriteCond %{REQUEST_URI} !\=
        RewriteCond %{REQUEST_URI} !\.
        RewriteCond %{REQUEST_URI} !\/$
        RewriteCond %{HTTP_HOST} ^www\.(.*)$
        RewriteRule ^(.*)$ https://%1/$1/ [L,R=301]
    
        RewriteCond %{REQUEST_URI} !\?
        RewriteCond %{REQUEST_URI} !\&
        RewriteCond %{REQUEST_URI} !\=
        RewriteCond %{REQUEST_URI} !\.
        RewriteCond %{REQUEST_URI} ![^\/]$
        RewriteCond %{HTTP_HOST} ^www\.(.*)$
        RewriteRule ^(.*)$ https://%1/$1 [L,R=301]
    
        RewriteCond %{REQUEST_URI} !\?
        RewriteCond %{REQUEST_URI} !\&
        RewriteCond %{REQUEST_URI} !\=
        RewriteCond %{REQUEST_URI} !\.
        RewriteCond %{REQUEST_URI} !\/$
        RewriteCond %{HTTP_HOST} ^([^www].*)$
        RewriteRule ^(.*)$ https://%1/$1/ [L,R=301]
    
    </IfModule>
    
    <IfModule mod_dir.c>
        DirectoryIndex index.php index.html
    </IfModule>
    
    <IfModule mod_expires.c>
        ExpiresActive on
        ExpiresByType image/jpeg "access plus 3 day"
        ExpiresByType image/gif "access plus 3 day"
    </IfModule>
    
    RewriteEngine on
    RewriteBase /
    RewriteCond %{HTTPS} !=on
    RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

Заранее спасибо !


Ответы (0 шт):