Setup Permanent 301 Redirects after moving to Https
i moved my site from http to https
now i want to redirect the user into the new url but evry time i'm trying to edit .htaccess file i'm getting an error
this is the working file content where xxxz is site name
# 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 %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]
what i'm trying to edit is to add the following code in the top of the file as i read
RewriteEngine on
RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]
but its not working so what do u think
htaccess ssl
New contributor
add a comment |
i moved my site from http to https
now i want to redirect the user into the new url but evry time i'm trying to edit .htaccess file i'm getting an error
this is the working file content where xxxz is site name
# 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 %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]
what i'm trying to edit is to add the following code in the top of the file as i read
RewriteEngine on
RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]
but its not working so what do u think
htaccess ssl
New contributor
Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
– Charles
2 hours ago
add a comment |
i moved my site from http to https
now i want to redirect the user into the new url but evry time i'm trying to edit .htaccess file i'm getting an error
this is the working file content where xxxz is site name
# 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 %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]
what i'm trying to edit is to add the following code in the top of the file as i read
RewriteEngine on
RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]
but its not working so what do u think
htaccess ssl
New contributor
i moved my site from http to https
now i want to redirect the user into the new url but evry time i'm trying to edit .htaccess file i'm getting an error
this is the working file content where xxxz is site name
# 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 %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]
what i'm trying to edit is to add the following code in the top of the file as i read
RewriteEngine on
RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]
but its not working so what do u think
htaccess ssl
htaccess ssl
New contributor
New contributor
New contributor
asked 5 hours ago
Abdullaziz Happy
112
112
New contributor
New contributor
Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
– Charles
2 hours ago
add a comment |
Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
– Charles
2 hours ago
Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
– Charles
2 hours ago
Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
– Charles
2 hours ago
add a comment |
2 Answers
2
active
oldest
votes
RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]
This will result in a redirect loop as it will repeatedly redirect https://www.xxxz.com.qa/<url>
to https://www.xxxz.com.qa/<url>
again and again...
If you want to redirect from HTTP then you need to check that the request was for HTTP before redirecting to HTTPS. For example:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
No need for the NC
flag, as you are simply matching everything anyway.
However, this conflicts with the existing directives at the end of your file:
RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]
These directives should probably be deleted. (Fortunately, they probably aren't doing anything anyway - because they are after the WordPress front-controller.)
add a comment |
The best way for setting up Permanent 301 Redirects is by editing .htaccess with the required redirection code. Follow these steps:
- Open your cPanel account.
- Click on File Manager under Files section.
- Click on public_html directory in the left sidebar.
- Search for the .htaccess file. Right-click on it. Click on Edit.
- A pop up box will appear. Click on Edit.
A new tab will be opened. Here, you have to add the
redirect code. For example, your old page is
https://yoursite.com/old-page.htm, and the new page is
https://yoursite.com/new-page.htm. In this case, the redirect code
will be:
Redirect 301 /old-page.htm/ /new-page.htm
You can find more information about these steps right here.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "110"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});
}
});
Abdullaziz Happy is a new contributor. Be nice, and check out our Code of Conduct.
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%2fwordpress.stackexchange.com%2fquestions%2f324345%2fsetup-permanent-301-redirects-after-moving-to-https%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]
This will result in a redirect loop as it will repeatedly redirect https://www.xxxz.com.qa/<url>
to https://www.xxxz.com.qa/<url>
again and again...
If you want to redirect from HTTP then you need to check that the request was for HTTP before redirecting to HTTPS. For example:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
No need for the NC
flag, as you are simply matching everything anyway.
However, this conflicts with the existing directives at the end of your file:
RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]
These directives should probably be deleted. (Fortunately, they probably aren't doing anything anyway - because they are after the WordPress front-controller.)
add a comment |
RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]
This will result in a redirect loop as it will repeatedly redirect https://www.xxxz.com.qa/<url>
to https://www.xxxz.com.qa/<url>
again and again...
If you want to redirect from HTTP then you need to check that the request was for HTTP before redirecting to HTTPS. For example:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
No need for the NC
flag, as you are simply matching everything anyway.
However, this conflicts with the existing directives at the end of your file:
RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]
These directives should probably be deleted. (Fortunately, they probably aren't doing anything anyway - because they are after the WordPress front-controller.)
add a comment |
RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]
This will result in a redirect loop as it will repeatedly redirect https://www.xxxz.com.qa/<url>
to https://www.xxxz.com.qa/<url>
again and again...
If you want to redirect from HTTP then you need to check that the request was for HTTP before redirecting to HTTPS. For example:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
No need for the NC
flag, as you are simply matching everything anyway.
However, this conflicts with the existing directives at the end of your file:
RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]
These directives should probably be deleted. (Fortunately, they probably aren't doing anything anyway - because they are after the WordPress front-controller.)
RewriteCond %{HTTP_HOST} ^xxxz.com.qa [NC,OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.com.qa [NC]
RewriteRule ^(.*)$ https://www.xxxz.com.qa/$1 [L,R=301,NC]
This will result in a redirect loop as it will repeatedly redirect https://www.xxxz.com.qa/<url>
to https://www.xxxz.com.qa/<url>
again and again...
If you want to redirect from HTTP then you need to check that the request was for HTTP before redirecting to HTTPS. For example:
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}/$1 [R=301,L]
No need for the NC
flag, as you are simply matching everything anyway.
However, this conflicts with the existing directives at the end of your file:
RewriteCond %{HTTP_HOST} ^xxxz.qa$ [OR]
RewriteCond %{HTTP_HOST} ^www.xxxz.qa$
RewriteCond %{REQUEST_URI} !^/.well-known/cpanel-dcv/[0-9a-zA-Z_-]+$
RewriteCond %{REQUEST_URI} !^/.well-known/pki-validation/[A-F0-9] {32}.txt(?: Comodo DCV)?$
RewriteRule ^/?$ "http://xxxz.com.qa" [R=301,L]
These directives should probably be deleted. (Fortunately, they probably aren't doing anything anyway - because they are after the WordPress front-controller.)
answered 1 hour ago
MrWhite
1,49411015
1,49411015
add a comment |
add a comment |
The best way for setting up Permanent 301 Redirects is by editing .htaccess with the required redirection code. Follow these steps:
- Open your cPanel account.
- Click on File Manager under Files section.
- Click on public_html directory in the left sidebar.
- Search for the .htaccess file. Right-click on it. Click on Edit.
- A pop up box will appear. Click on Edit.
A new tab will be opened. Here, you have to add the
redirect code. For example, your old page is
https://yoursite.com/old-page.htm, and the new page is
https://yoursite.com/new-page.htm. In this case, the redirect code
will be:
Redirect 301 /old-page.htm/ /new-page.htm
You can find more information about these steps right here.
add a comment |
The best way for setting up Permanent 301 Redirects is by editing .htaccess with the required redirection code. Follow these steps:
- Open your cPanel account.
- Click on File Manager under Files section.
- Click on public_html directory in the left sidebar.
- Search for the .htaccess file. Right-click on it. Click on Edit.
- A pop up box will appear. Click on Edit.
A new tab will be opened. Here, you have to add the
redirect code. For example, your old page is
https://yoursite.com/old-page.htm, and the new page is
https://yoursite.com/new-page.htm. In this case, the redirect code
will be:
Redirect 301 /old-page.htm/ /new-page.htm
You can find more information about these steps right here.
add a comment |
The best way for setting up Permanent 301 Redirects is by editing .htaccess with the required redirection code. Follow these steps:
- Open your cPanel account.
- Click on File Manager under Files section.
- Click on public_html directory in the left sidebar.
- Search for the .htaccess file. Right-click on it. Click on Edit.
- A pop up box will appear. Click on Edit.
A new tab will be opened. Here, you have to add the
redirect code. For example, your old page is
https://yoursite.com/old-page.htm, and the new page is
https://yoursite.com/new-page.htm. In this case, the redirect code
will be:
Redirect 301 /old-page.htm/ /new-page.htm
You can find more information about these steps right here.
The best way for setting up Permanent 301 Redirects is by editing .htaccess with the required redirection code. Follow these steps:
- Open your cPanel account.
- Click on File Manager under Files section.
- Click on public_html directory in the left sidebar.
- Search for the .htaccess file. Right-click on it. Click on Edit.
- A pop up box will appear. Click on Edit.
A new tab will be opened. Here, you have to add the
redirect code. For example, your old page is
https://yoursite.com/old-page.htm, and the new page is
https://yoursite.com/new-page.htm. In this case, the redirect code
will be:
Redirect 301 /old-page.htm/ /new-page.htm
You can find more information about these steps right here.
answered 1 hour ago
Md. Ehsanul Haque Kanan
785
785
add a comment |
add a comment |
Abdullaziz Happy is a new contributor. Be nice, and check out our Code of Conduct.
Abdullaziz Happy is a new contributor. Be nice, and check out our Code of Conduct.
Abdullaziz Happy is a new contributor. Be nice, and check out our Code of Conduct.
Abdullaziz Happy is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to WordPress Development Stack Exchange!
- 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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2fwordpress.stackexchange.com%2fquestions%2f324345%2fsetup-permanent-301-redirects-after-moving-to-https%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
Welcome to WPSE, I assume you have taken a look on the numerous answers as given here?!
– Charles
2 hours ago