0

Hi how can I redirect toptangiy.com and www.toptangiy.com redirect to https://www.toptangiy.com

<IfModule mod_rewrite.c>

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^toptangiy.com$
RewriteRule (.*) https://www.toptangiy.com/$1 [R=301,L]

</IfModule>

This is my htaccess after this codes site write err too many redirects

6
  • Your first condition doesn't include www in the redirect. Commented Sep 12, 2018 at 5:51
  • I would suggest that you do a search on the subject before posting. This is a common question with many examples here on SO alone.Try: "apache redirect to https". I'm quite sure you will find some that fits your case more or less exactly. If not, take one that works and modify it to fit your needs. Commented Sep 12, 2018 at 6:04
  • i am need only correct codes for redirecting link Commented Sep 12, 2018 at 6:07
  • this will help in redirecting all traffic to https RewriteEngine On RewriteCond %{HTTPS} off RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} Commented Sep 12, 2018 at 6:08
  • Follow the following link: Redirecting from HTTP to HTTPS with PHP Commented Sep 12, 2018 at 6:12

1 Answer 1

1

If the task is enforce https and www for a domain, it's a very common task, and there's lots of answers on StackOverflow for it. But as far as the way I'd write this for your case, I'd use:

<IfModule mod_rewrite.c>
    RewriteEngine On

    # Enforce https for toptangiy.com
    RewriteCond %{HTTPS} off
    RewriteCond %{HTTP_HOST} ^www.toptangiy.com$
    RewriteRule (.*) https://www.toptangiy.com/$1 [R=301,L]

    # Enforce www for toptangiy.com
    RewriteCond %{HTTP_HOST} ^toptangiy.com$
    RewriteRule (.*) https://www.toptangiy.com/$1 [R=301,L]
</IfModule>
Sign up to request clarification or add additional context in comments.

15 Comments

i remove that and same problem
i can write you my admin panel password you can control that ?
@JrAa Made an adjustment. Due to a permanent 301 redirect being used, browsers will cache previous redirects.Try testing on websniffer.cc
@7060965 That's simply incorrect. The rewrite rule only matches the / and does not include the domain. When testing on htaccess.madewithlove.be you need to include the scheme in the request url you're testing on as noted on the site.
@JrAa don't share cpanel user name and password in comments. if you trust some one then share on email instead of comments or public platform
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.