Home Htaccess URLs redirects are working for http not all https
Reply: 0

Htaccess URLs redirects are working for http not all https

user5737 Published in September 19, 2018, 3:18 am

newbie on htaccess and redirects, I hope someone can help me with this. At the moment all the http urls are redirecting correctly. E.g. if you go to otherdomain.com it will take you to the maindomian.com.

This is currently not working for all of the https links.

For example: http - both www and non www otherdomain.com/blog will redirect to https://www.mainwebsite.com/blog

Which is what I need, however as soon as I get to the https it does the following:

https - both www and non www otherdomain.com/blog will remain on the https otherdomain.com/blog domain.

Which is wrong because it needs to go to the main website's blog page. But if I have manually added a redirect on a page all the http and https urls will work: E.g. both www and non www http://www.otherdomain.com/newpage will redirect to https://www.mainwebsite.com/welcome https://www.otherdomain.com/newpage will redirect to https://www.mainwebsite.com/welcome

It's Drupal 7, here is the code that I currently have:

Redirect /newpage                                       https://www.mainwebsite.com/welcome

    RewriteEngine on
    RewriteBase /

    # Force HTTPS 
    RewriteCond %{HTTPS} off
    RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

    # Remove trailing slash
    RewriteRule ^(.*)/$ https://%{HTTP_HOST}/$1 [R=301,L]

    RewriteCond %{HTTP_HOST} ^mainwebsite.com$ [NC]
    RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

    # Set "protossl" to "s" if we were accessed via https://.  This is used later
    # if you enable "www." stripping or enforcement, in order to ensure that
    # you don't bounce between http and https.
    RewriteRule ^ - [E=protossl]
    RewriteCond %{HTTPS} on
    RewriteRule ^ - [E=protossl:s]

    # Make sure Authorization HTTP header is available to PHP
    # even when running as CGI or FastCGI.
    RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

        # Pass all requests not referring directly to files in the filesystem to
    # index.php. Clean URLs are handled in drupal_environment_initialize().
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !=/favicon.ico
    RewriteRule ^ index.php [L]

Any idea how I can get any url from the https otherdomain.com to go to the mainwebsite.com? Any help would be greatly appreciated.

share|improve this question

1 Answer 1

active oldest votes
up vote 0 down vote accepted
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.292441 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO