Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    CBG
    CBG is offline
    New Coder
    Join Date
    Feb 2010
    Location
    UK
    Posts
    91
    Thanks
    26
    Thanked 0 Times in 0 Posts

    Question htaccess rewriterule HTTP work fine HTTPS is the problem

    Hi,

    I have the below rewrite rule
    Code:
    RewriteRule ^([a-zA-Z0-9_-]+)$ profile.php?username=$1
    When I go to: http://www.mydomain.co/ABC
    It works fine

    When I go to: https://www.mydomain.co/ABC

    It redirects to: http://www.mydomain.co/ABC?username=ABC
    I am not wanting ?username=ABC when being redirected for HTTPS

    I am wanting to make access to this via HTTP only.
    I have tried to add ? in places to strip but that didn't work and broke it

    Any help please
    Regards,
    CBG

  • #2
    CBG
    CBG is offline
    New Coder
    Join Date
    Feb 2010
    Location
    UK
    Posts
    91
    Thanks
    26
    Thanked 0 Times in 0 Posts
    Ok how does this look, it seems to work, just a bit worried about the NC on the last RewriteRule. As I have been told NC can create opportunities for duplicate content

    Code:
    RewriteCond %{THE_REQUEST} ^[a-zA-Z0-9_-]+\ /profile\.php\?username=([^&]+)\ HTTP/
    RewriteRule ^profile\.php$ http://www.mydomain.co/%1? [R=301,L]
    RewriteRule ^([a-z0-9_]+)/?$ profile.php?username=$1 [NC,L]
    The idea is http://www.mydomain.co/ABC is normal URL, but if anyone tries https://www.mydomain.co/ABC they redirected back to http
    Regards,
    CBG


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •