Jump to content

htaccess rewriterule HTTP work fine HTTPS is the problem


CBG

Recommended Posts

Hi,

 

I have the below rewrite rule

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

Link to comment
Share on other sites

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

 

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.