Support » Fixing WordPress » http to specific URL using htaccess in WordPress

  • sktrader

    (@sktrader)


    I am looking for help with the htaccess redirect rules.

    I have url www.example.com.au and I want the following redirection
    
    https://www.example.com.au =>https://www.example.com.au
    http://www.example.com.au =>https://www.example.com.au/page-2

    I found the following .htaccess rules but its not working for me

    RewriteEngine On
    RewriteCond %{HTTP_HOST} www^example\.com.au [NC]
    RewriteCond %{HTTPS} off
    RewriteRule ^(.*)$ https://%. 
    {HTTP_HOST}%www^example.com.au/page-2 [302 L]

    I will be using the above rule for a WordPress site so do i need to paste the above rules at the bottom so that it doesn’t overruled by other rewrite rule?

    Thanks in advance.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Naveenkumar C

    (@cnaveenkumar)

    Hi @sktrader,

    Try this

    
    # http -> https
    RewriteEngine On
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
    

    Thanks

    Thread Starter sktrader

    (@sktrader)

    Thank you Naveen for your reply.
    Can I please ask how it would redirect to specific URL?
    Can I specify a URL at https://%{HTTP_HOST}%{REQUEST_URI} if yes then how it will look like?

    Naveenkumar C

    (@cnaveenkumar)

    Try this one

    
    Redirect http://www.example.com.au /page-2/
    
    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    Moved to Fixing WordPress, this is not a Developing with WordPress topic.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘http to specific URL using htaccess in WordPress’ is closed to new replies.