justyy
justyy

Reputation: 6041

curl says it is 302 but in .htaccess i have 301

I have a VPS server, and I just added a new site, and I run the command:

curl -I --resolve isvbscriptdead.com:80:IP_ADDRESS_HERE http://isvbscriptdead.com
HTTP/1.1 302 Found
Date: Wed, 22 Jun 2016 09:41:28 GMT
Server: Apache/2.4.7 (Ubuntu)
Location: https://isvbscriptdead.com/
Content-Type: text/html; charset=iso-8859-1

Why it is a 302 redirection? I have added a .htaccess that redirects all non-www HTTPS to HTTPS:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{ENV:HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,R=301,NE]
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.*)$ /index.php?id=$1 [L]
RewriteCond %{HTTP_HOST} !^isvbscriptdead.com$ [NC]
RewriteRule ^(.*)$ http://isvbscriptdead.com/$1 [L,R=301]

So why is curl reporting a 302?

Upvotes: 0

Views: 443

Answers (1)

justyy
justyy

Reputation: 6041

Finally figure out the cause:

My VPS comes with two IPs, if the IP in the curl is different than the one recorded in the name server, then it will give a 302 move temporarily redirection. If the IP is exactly the same with the curl command, then it shows 301 move permanent redirection.

Not sure why it behaves like this, but good to know it is not a big problem and it kinda makes sense.

Upvotes: 1

Related Questions