.htaccess redirects to remove php and redirect to https and non-www
up vote
1
down vote
favorite
I have the following in my .htaccess
file to
- Remove www
- Redirect to https
- remove .php
This is my .htaccess:
# ----------------------------------------------------------------------
# | Redirect to HTTPS & remove www |
# ----------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www. [NC]
RewriteCond %{HTTP_HOST} ^(?:www.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
# ----------------------------------------------------------------------
# | Remove .php extension |
# ----------------------------------------------------------------------
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
When I view the site in Firefox I get the following error:
The page isn't redirecting properly.
This problem can sometimes be caused by disabling or refusing to accept cookies
And Chrome warns about too many redirects
The URL is updated to what I would expect (www removed and https added). There are no other redirects in effect
Can anyone spot where I am going wrong?
.htaccess
This question has an open bounty worth +150
reputation from Mike Harrison ending in 3 days.
This question has not received enough attention.
add a comment |
up vote
1
down vote
favorite
I have the following in my .htaccess
file to
- Remove www
- Redirect to https
- remove .php
This is my .htaccess:
# ----------------------------------------------------------------------
# | Redirect to HTTPS & remove www |
# ----------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www. [NC]
RewriteCond %{HTTP_HOST} ^(?:www.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
# ----------------------------------------------------------------------
# | Remove .php extension |
# ----------------------------------------------------------------------
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
When I view the site in Firefox I get the following error:
The page isn't redirecting properly.
This problem can sometimes be caused by disabling or refusing to accept cookies
And Chrome warns about too many redirects
The URL is updated to what I would expect (www removed and https added). There are no other redirects in effect
Can anyone spot where I am going wrong?
.htaccess
This question has an open bounty worth +150
reputation from Mike Harrison ending in 3 days.
This question has not received enough attention.
1
I can't see anything that would cause a redirect loop. There must be something in conflict, like other rules ? Could you tell what url the redirect loop generates ? That'd help to debug it
– Justin Iurman
Nov 14 at 11:15
Hi Justin - url generated is correct, and there are no other redirect rules. I have updated the question to include this information
– Mike Harrison
2 days ago
Actually, what you see is not what you get, proof is the redirect loop. Could you look in the network console of Chrome to see what's wrong ? This way, we'll see what's the redirect loop and we could determine the source of the problem. High is the chance that you have a CMS (do you ?) that is configured to accepthttp
orwww
(or both) only, which would explain the redirect loop.
– Justin Iurman
2 days ago
What is your Apache version? Try replacingRewriteCond %{HTTPS} off [OR]
wiithRewriteCond %{REQUEST_SCHEME} =http
– anubhava
17 hours ago
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I have the following in my .htaccess
file to
- Remove www
- Redirect to https
- remove .php
This is my .htaccess:
# ----------------------------------------------------------------------
# | Redirect to HTTPS & remove www |
# ----------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www. [NC]
RewriteCond %{HTTP_HOST} ^(?:www.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
# ----------------------------------------------------------------------
# | Remove .php extension |
# ----------------------------------------------------------------------
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
When I view the site in Firefox I get the following error:
The page isn't redirecting properly.
This problem can sometimes be caused by disabling or refusing to accept cookies
And Chrome warns about too many redirects
The URL is updated to what I would expect (www removed and https added). There are no other redirects in effect
Can anyone spot where I am going wrong?
.htaccess
I have the following in my .htaccess
file to
- Remove www
- Redirect to https
- remove .php
This is my .htaccess:
# ----------------------------------------------------------------------
# | Redirect to HTTPS & remove www |
# ----------------------------------------------------------------------
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www. [NC]
RewriteCond %{HTTP_HOST} ^(?:www.)?(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
# ----------------------------------------------------------------------
# | Remove .php extension |
# ----------------------------------------------------------------------
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^(.+?)/?$ /$1.php [L]
When I view the site in Firefox I get the following error:
The page isn't redirecting properly.
This problem can sometimes be caused by disabling or refusing to accept cookies
And Chrome warns about too many redirects
The URL is updated to what I would expect (www removed and https added). There are no other redirects in effect
Can anyone spot where I am going wrong?
.htaccess
.htaccess
edited 2 days ago
asked Nov 8 at 10:57
Mike Harrison
5651624
5651624
This question has an open bounty worth +150
reputation from Mike Harrison ending in 3 days.
This question has not received enough attention.
This question has an open bounty worth +150
reputation from Mike Harrison ending in 3 days.
This question has not received enough attention.
1
I can't see anything that would cause a redirect loop. There must be something in conflict, like other rules ? Could you tell what url the redirect loop generates ? That'd help to debug it
– Justin Iurman
Nov 14 at 11:15
Hi Justin - url generated is correct, and there are no other redirect rules. I have updated the question to include this information
– Mike Harrison
2 days ago
Actually, what you see is not what you get, proof is the redirect loop. Could you look in the network console of Chrome to see what's wrong ? This way, we'll see what's the redirect loop and we could determine the source of the problem. High is the chance that you have a CMS (do you ?) that is configured to accepthttp
orwww
(or both) only, which would explain the redirect loop.
– Justin Iurman
2 days ago
What is your Apache version? Try replacingRewriteCond %{HTTPS} off [OR]
wiithRewriteCond %{REQUEST_SCHEME} =http
– anubhava
17 hours ago
add a comment |
1
I can't see anything that would cause a redirect loop. There must be something in conflict, like other rules ? Could you tell what url the redirect loop generates ? That'd help to debug it
– Justin Iurman
Nov 14 at 11:15
Hi Justin - url generated is correct, and there are no other redirect rules. I have updated the question to include this information
– Mike Harrison
2 days ago
Actually, what you see is not what you get, proof is the redirect loop. Could you look in the network console of Chrome to see what's wrong ? This way, we'll see what's the redirect loop and we could determine the source of the problem. High is the chance that you have a CMS (do you ?) that is configured to accepthttp
orwww
(or both) only, which would explain the redirect loop.
– Justin Iurman
2 days ago
What is your Apache version? Try replacingRewriteCond %{HTTPS} off [OR]
wiithRewriteCond %{REQUEST_SCHEME} =http
– anubhava
17 hours ago
1
1
I can't see anything that would cause a redirect loop. There must be something in conflict, like other rules ? Could you tell what url the redirect loop generates ? That'd help to debug it
– Justin Iurman
Nov 14 at 11:15
I can't see anything that would cause a redirect loop. There must be something in conflict, like other rules ? Could you tell what url the redirect loop generates ? That'd help to debug it
– Justin Iurman
Nov 14 at 11:15
Hi Justin - url generated is correct, and there are no other redirect rules. I have updated the question to include this information
– Mike Harrison
2 days ago
Hi Justin - url generated is correct, and there are no other redirect rules. I have updated the question to include this information
– Mike Harrison
2 days ago
Actually, what you see is not what you get, proof is the redirect loop. Could you look in the network console of Chrome to see what's wrong ? This way, we'll see what's the redirect loop and we could determine the source of the problem. High is the chance that you have a CMS (do you ?) that is configured to accept
http
or www
(or both) only, which would explain the redirect loop.– Justin Iurman
2 days ago
Actually, what you see is not what you get, proof is the redirect loop. Could you look in the network console of Chrome to see what's wrong ? This way, we'll see what's the redirect loop and we could determine the source of the problem. High is the chance that you have a CMS (do you ?) that is configured to accept
http
or www
(or both) only, which would explain the redirect loop.– Justin Iurman
2 days ago
What is your Apache version? Try replacing
RewriteCond %{HTTPS} off [OR]
wiithRewriteCond %{REQUEST_SCHEME} =http
– anubhava
17 hours ago
What is your Apache version? Try replacing
RewriteCond %{HTTPS} off [OR]
wiithRewriteCond %{REQUEST_SCHEME} =http
– anubhava
17 hours ago
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53206318%2fhtaccess-redirects-to-remove-php-and-redirect-to-https-and-non-www%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I can't see anything that would cause a redirect loop. There must be something in conflict, like other rules ? Could you tell what url the redirect loop generates ? That'd help to debug it
– Justin Iurman
Nov 14 at 11:15
Hi Justin - url generated is correct, and there are no other redirect rules. I have updated the question to include this information
– Mike Harrison
2 days ago
Actually, what you see is not what you get, proof is the redirect loop. Could you look in the network console of Chrome to see what's wrong ? This way, we'll see what's the redirect loop and we could determine the source of the problem. High is the chance that you have a CMS (do you ?) that is configured to accept
http
orwww
(or both) only, which would explain the redirect loop.– Justin Iurman
2 days ago
What is your Apache version? Try replacing
RewriteCond %{HTTPS} off [OR]
wiithRewriteCond %{REQUEST_SCHEME} =http
– anubhava
17 hours ago