.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?










share|improve this question

















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 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















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?










share|improve this question

















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 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













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?










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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














  • 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 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








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

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Schultheiß

Verwaltungsgliederung Dänemarks

Liste der Kulturdenkmale in Wilsdruff