Creating the most efficient .htaccess file
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I have been asked to clean up a htaccess file.
Here is the current code:
RewriteOptions inherit
# This file was updated by Duplicator on 2018-05-01 07:23:35. See .htaccess.orig for the original .htaccess file.
# Please note that other plugins and resources write to this file. If the time-stamp above is different
# than the current time-stamp on the file system then another resource has updated this file.
# Duplicator only writes to this file once during the install process while running the installer.php file.
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token, User-Agent, Content-Disposition"
Header always set Access-Control-Expose-Headers "Content-Disposition"
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# RewriteCond %{HTTPS} off
# RewriteCond %{HTTP:X-Forwarded-SSL} off
# RewriteCond %{HTTP_HOST} ^example.com$ [OR]
# RewriteCond %{HTTP_HOST} ^www.example.com$
# RewriteRule ^(.*)$ "https://www.example.com/$1" [R=301,L]
# RewriteEngine On
# RewriteCond %{HTTP_HOST} ^example.com/com [NC]
# RewriteCond %{SERVER_PORT} 80
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
A couple points:
In my SEO report it states 'No redirect or canonical to HTTPS homepage from HTTP version'.
~ even though I have a declaration in my header file that sets the canonical link, also the htaccess file currently redirects to the https version.
~ Apparently a 301 redirect will fix the above issue - from what I have read.
~ This is the reason I have been asked to look into this file.
I wish for the site to redirect to the https version.
I wish to keep the local caching of images.
Feel free to remove commented out lines if this doesn't help
What is the best practice to achieve the results I currently am getting but so it uses a '301 redirect' with less clutter in the code?
Any help / advice you can provide would be great!
Thanks, Jason.
wordpress .htaccess
|
show 1 more comment
I have been asked to clean up a htaccess file.
Here is the current code:
RewriteOptions inherit
# This file was updated by Duplicator on 2018-05-01 07:23:35. See .htaccess.orig for the original .htaccess file.
# Please note that other plugins and resources write to this file. If the time-stamp above is different
# than the current time-stamp on the file system then another resource has updated this file.
# Duplicator only writes to this file once during the install process while running the installer.php file.
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token, User-Agent, Content-Disposition"
Header always set Access-Control-Expose-Headers "Content-Disposition"
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# RewriteCond %{HTTPS} off
# RewriteCond %{HTTP:X-Forwarded-SSL} off
# RewriteCond %{HTTP_HOST} ^example.com$ [OR]
# RewriteCond %{HTTP_HOST} ^www.example.com$
# RewriteRule ^(.*)$ "https://www.example.com/$1" [R=301,L]
# RewriteEngine On
# RewriteCond %{HTTP_HOST} ^example.com/com [NC]
# RewriteCond %{SERVER_PORT} 80
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
A couple points:
In my SEO report it states 'No redirect or canonical to HTTPS homepage from HTTP version'.
~ even though I have a declaration in my header file that sets the canonical link, also the htaccess file currently redirects to the https version.
~ Apparently a 301 redirect will fix the above issue - from what I have read.
~ This is the reason I have been asked to look into this file.
I wish for the site to redirect to the https version.
I wish to keep the local caching of images.
Feel free to remove commented out lines if this doesn't help
What is the best practice to achieve the results I currently am getting but so it uses a '301 redirect' with less clutter in the code?
Any help / advice you can provide would be great!
Thanks, Jason.
wordpress .htaccess
Sorry, but do you hacve a specific question here?
– arkascha
Jan 3 at 10:02
No apology necessary. What is the best practice to achieve the results I currently am getting but so it uses a '301 redirect' with less clutter in the code?
– Jason Is My Name
Jan 3 at 10:19
1
If you are currently redirected with a 302, then change[R,L]
to[R=301]
. Note: theL
flag is not required with an external redirection anyway.
– arkascha
Jan 3 at 10:46
@arkascha - please put this into an answer so I can appreciate your answer... c:
– Jason Is My Name
Jan 3 at 11:45
@arkascha - at the top of the document there is a line 'RewriteOptions inherit' followed by commented out lines. Are you able to also inform me on wether this is still required?
– Jason Is My Name
Jan 3 at 11:46
|
show 1 more comment
I have been asked to clean up a htaccess file.
Here is the current code:
RewriteOptions inherit
# This file was updated by Duplicator on 2018-05-01 07:23:35. See .htaccess.orig for the original .htaccess file.
# Please note that other plugins and resources write to this file. If the time-stamp above is different
# than the current time-stamp on the file system then another resource has updated this file.
# Duplicator only writes to this file once during the install process while running the installer.php file.
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token, User-Agent, Content-Disposition"
Header always set Access-Control-Expose-Headers "Content-Disposition"
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# RewriteCond %{HTTPS} off
# RewriteCond %{HTTP:X-Forwarded-SSL} off
# RewriteCond %{HTTP_HOST} ^example.com$ [OR]
# RewriteCond %{HTTP_HOST} ^www.example.com$
# RewriteRule ^(.*)$ "https://www.example.com/$1" [R=301,L]
# RewriteEngine On
# RewriteCond %{HTTP_HOST} ^example.com/com [NC]
# RewriteCond %{SERVER_PORT} 80
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
A couple points:
In my SEO report it states 'No redirect or canonical to HTTPS homepage from HTTP version'.
~ even though I have a declaration in my header file that sets the canonical link, also the htaccess file currently redirects to the https version.
~ Apparently a 301 redirect will fix the above issue - from what I have read.
~ This is the reason I have been asked to look into this file.
I wish for the site to redirect to the https version.
I wish to keep the local caching of images.
Feel free to remove commented out lines if this doesn't help
What is the best practice to achieve the results I currently am getting but so it uses a '301 redirect' with less clutter in the code?
Any help / advice you can provide would be great!
Thanks, Jason.
wordpress .htaccess
I have been asked to clean up a htaccess file.
Here is the current code:
RewriteOptions inherit
# This file was updated by Duplicator on 2018-05-01 07:23:35. See .htaccess.orig for the original .htaccess file.
# Please note that other plugins and resources write to this file. If the time-stamp above is different
# than the current time-stamp on the file system then another resource has updated this file.
# Duplicator only writes to this file once during the install process while running the installer.php file.
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token, User-Agent, Content-Disposition"
Header always set Access-Control-Expose-Headers "Content-Disposition"
# Added a rewrite to respond with a 200 SUCCESS on every OPTIONS request.
RewriteEngine On
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L]
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# RewriteCond %{HTTPS} off
# RewriteCond %{HTTP:X-Forwarded-SSL} off
# RewriteCond %{HTTP_HOST} ^example.com$ [OR]
# RewriteCond %{HTTP_HOST} ^www.example.com$
# RewriteRule ^(.*)$ "https://www.example.com/$1" [R=301,L]
# RewriteEngine On
# RewriteCond %{HTTP_HOST} ^example.com/com [NC]
# RewriteCond %{SERVER_PORT} 80
# RewriteCond %{HTTPS} off
# RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
A couple points:
In my SEO report it states 'No redirect or canonical to HTTPS homepage from HTTP version'.
~ even though I have a declaration in my header file that sets the canonical link, also the htaccess file currently redirects to the https version.
~ Apparently a 301 redirect will fix the above issue - from what I have read.
~ This is the reason I have been asked to look into this file.
I wish for the site to redirect to the https version.
I wish to keep the local caching of images.
Feel free to remove commented out lines if this doesn't help
What is the best practice to achieve the results I currently am getting but so it uses a '301 redirect' with less clutter in the code?
Any help / advice you can provide would be great!
Thanks, Jason.
wordpress .htaccess
wordpress .htaccess
edited Jan 3 at 10:20
Jason Is My Name
asked Jan 3 at 9:58


Jason Is My NameJason Is My Name
11615
11615
Sorry, but do you hacve a specific question here?
– arkascha
Jan 3 at 10:02
No apology necessary. What is the best practice to achieve the results I currently am getting but so it uses a '301 redirect' with less clutter in the code?
– Jason Is My Name
Jan 3 at 10:19
1
If you are currently redirected with a 302, then change[R,L]
to[R=301]
. Note: theL
flag is not required with an external redirection anyway.
– arkascha
Jan 3 at 10:46
@arkascha - please put this into an answer so I can appreciate your answer... c:
– Jason Is My Name
Jan 3 at 11:45
@arkascha - at the top of the document there is a line 'RewriteOptions inherit' followed by commented out lines. Are you able to also inform me on wether this is still required?
– Jason Is My Name
Jan 3 at 11:46
|
show 1 more comment
Sorry, but do you hacve a specific question here?
– arkascha
Jan 3 at 10:02
No apology necessary. What is the best practice to achieve the results I currently am getting but so it uses a '301 redirect' with less clutter in the code?
– Jason Is My Name
Jan 3 at 10:19
1
If you are currently redirected with a 302, then change[R,L]
to[R=301]
. Note: theL
flag is not required with an external redirection anyway.
– arkascha
Jan 3 at 10:46
@arkascha - please put this into an answer so I can appreciate your answer... c:
– Jason Is My Name
Jan 3 at 11:45
@arkascha - at the top of the document there is a line 'RewriteOptions inherit' followed by commented out lines. Are you able to also inform me on wether this is still required?
– Jason Is My Name
Jan 3 at 11:46
Sorry, but do you hacve a specific question here?
– arkascha
Jan 3 at 10:02
Sorry, but do you hacve a specific question here?
– arkascha
Jan 3 at 10:02
No apology necessary. What is the best practice to achieve the results I currently am getting but so it uses a '301 redirect' with less clutter in the code?
– Jason Is My Name
Jan 3 at 10:19
No apology necessary. What is the best practice to achieve the results I currently am getting but so it uses a '301 redirect' with less clutter in the code?
– Jason Is My Name
Jan 3 at 10:19
1
1
If you are currently redirected with a 302, then change
[R,L]
to [R=301]
. Note: the L
flag is not required with an external redirection anyway.– arkascha
Jan 3 at 10:46
If you are currently redirected with a 302, then change
[R,L]
to [R=301]
. Note: the L
flag is not required with an external redirection anyway.– arkascha
Jan 3 at 10:46
@arkascha - please put this into an answer so I can appreciate your answer... c:
– Jason Is My Name
Jan 3 at 11:45
@arkascha - please put this into an answer so I can appreciate your answer... c:
– Jason Is My Name
Jan 3 at 11:45
@arkascha - at the top of the document there is a line 'RewriteOptions inherit' followed by commented out lines. Are you able to also inform me on wether this is still required?
– Jason Is My Name
Jan 3 at 11:46
@arkascha - at the top of the document there is a line 'RewriteOptions inherit' followed by commented out lines. Are you able to also inform me on wether this is still required?
– Jason Is My Name
Jan 3 at 11:46
|
show 1 more comment
0
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',
autoActivateHeartbeat: false,
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
});
}
});
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%2f54019936%2fcreating-the-most-efficient-htaccess-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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%2f54019936%2fcreating-the-most-efficient-htaccess-file%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
Sorry, but do you hacve a specific question here?
– arkascha
Jan 3 at 10:02
No apology necessary. What is the best practice to achieve the results I currently am getting but so it uses a '301 redirect' with less clutter in the code?
– Jason Is My Name
Jan 3 at 10:19
1
If you are currently redirected with a 302, then change
[R,L]
to[R=301]
. Note: theL
flag is not required with an external redirection anyway.– arkascha
Jan 3 at 10:46
@arkascha - please put this into an answer so I can appreciate your answer... c:
– Jason Is My Name
Jan 3 at 11:45
@arkascha - at the top of the document there is a line 'RewriteOptions inherit' followed by commented out lines. Are you able to also inform me on wether this is still required?
– Jason Is My Name
Jan 3 at 11:46