简体   繁体   中英

htaccess http to https redirecting to REWRITE but appending php GET

My http to https redirect is 301 redirecting but it is including the appending PHP from the Rewrite Rule. For example:

http://www.testsite.com/staff/james/ is redirecting to https://www.testsite.com/staff/?hookName=james

Here is my https redirect:

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

My rewrite rule is:

RewriteRule ^/staff/(.*)/$ staff.php?hookName=$1

On my PHP page, I can obviously 301 it to the correct link. However, I'm trying to stop it from happening in the first place so I don't have a double 301.

Any ideas?

In your case, placing the internal rewrite under the external redirect will fix the problem. Please note that since you used a 301 redirect, the browser might have cached the old redirect, completely bypassing the server. Either use a different url you haven't tried before, try it in a different browser you haven't tested in before, or clear your cache. In the future, I would recommend turning all redirects into 302 (or temporary) redirects until you have thoroughly tested that everything works as expected.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM