I have a site with Wordpress. I need some single page to redirect HTTPS
I get code form stackoverflow and put in .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} /online-order-auto [NC]
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} !/online-order-auto [NC]
RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
RewriteCond %{HTTP_HOST} ^(www\.)?site\.com\.swtest\.ru$
RewriteRule ^(.*)$ http://www.site.ru/$1 [L,R=301]
The browser wrote "ERR_TOO_MANY_REDIRECTS".
I cant understand whats a problem
Try this. I've been looking all over and this is the only way I could make it work...
#non-www. http to www. https
RewriteCond %{ENV:HTTPS} !on
RewriteCond %{HTTP_HOST} ^(www\.)?yourdomain\.com$
RewriteRule (.*) https://www.yourdomain.com/$1 [R=301,L]
#non-www. https to www. https
RewriteCond %{ENV:HTTPS} on
RewriteCond %{HTTP_HOST} ^yourdomain\.com$
RewriteRule (.*) https://www.yourdomain.com/$1 [R=301,L]
Related
I have the following redirects in htaccess Wordpress is installed in home folder The site must redirect an example.com (without www) and with https
The wordpress installation is in / home
And I don't know how to fix it. Any suggestions? Thank you !!
RewriteCond %{HTTP_HOST} ^example.com$
RewriteCond %{REQUEST_URI} !^/home/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /home/$1
RewriteCond %{HTTP_HOST} ^example.com$
RewriteRule ^(/)?$ home/index.php [L]
# BEGIN SSL
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_USER_AGENT} ^(.+)$
RewriteCond %{SERVER_NAME} ^example\.com$
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
Header add Strict-Transport-Security "max-age=300"
</IfModule>
# END SSL```
You can't force subfolder or subdomain to redirect to https
for https redirection just use this
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
For Subfolder
RewriteRule ^/?(.*) https://%{SERVER_NAME}/home/$1 [R,L]
also you can use the default .htaccess for redirection
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
For a main domain (.nl) everything is forced over https and www.
However there is a small bug with parked domain .be
when accessed like https://domain.be/example the www. is not added.
In all other cases it is working.
.htaccess i have so far is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteCond %{HTTP_HOST} ^(.+)$ [NC]
RewriteRule ^(.*)$ https://www\.%1/$1 [R=301,L]
</IfModule>
Any ideas would be welcome!
Might want to check this
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
So in my htaccess file for a Wordpress site I have:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
I want all urls whatever entered to go to https://example.com (https, no www.)
At the moment this works well here:
http://example.com = https://example.com
www.example.com = https://example.com
However when on a page it doesn't work:
http://example.com/page/ = example.com/page/
www.example.com/page/ = example.com/page/
How can I make this go to the https version?
Change you htaccess file to below and it will work for you.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}/ [L,R=301]
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^$ https://example.com/? [L,R=301]
</IfModule>
You can use:
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
You can try using this in your .htaccess:
RewriteEngine on
RewriteBase /
RewriteCond %{HTTPS} !=on [OR]
RewriteCond %{HTTP_HOST} ^www\.
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [NE,L,R=301]
This seems to have done to the trick...
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I'm trying to redirect my entire blog to a new domain without redirecting the admin area.
The code I use is as follows:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^old-domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^/wp-login
RewriteCond %{REQUEST_URI} !^/wp-admin
RewriteRule ^(.*)$ http://new-domain.com/$1 [R=301,L]
But still I'm getting redirected to the new domain when I go to old-domain.com/wp-admin
Can anybody help?
Thanks.
Try:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^old-domain.com$ [NC]
RewriteCond %{REQUEST_URI} !^(.*)?wp-login\.php(.*)$
RewriteCond %{REQUEST_URI} !^(.*)?wp-admin$
RewriteRule ^(.*)$ http://new-domain.com/$1 [R=301,L]
This worked for me...
# Redirect all requests except wp-admin
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^(.*)?wp-login\.php(.*)$
RewriteCond %{REQUEST_URI} !^(.*)?wp-admin$
RewriteCond %{REQUEST_URI} !^/(wp-includes/.*|wp-admin/.*|wp-content/.*)$
RewriteRule ^(.*)$ http://new.com [R=301,L]
# 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
This is with the reference of Fake URLs created automaticly. which was solved by https://stackoverflow.com/users/548225/anubhava.
By mistake or spam too many URLs have been created like below but now i want to redirect them to their respective post page URL.
I would prefer .htaccess. Please help
abc.com/wp-admin/post.php?post=4051&action=edit
**Redirect to**
abc.com/?p=4051
and
abc.com/page/56/?option=com_content&view=article&id=94&Itemid=2
**Redirect to**
abc.com/page/56/
and
abc.com/category5/post-about-fashion/function.include
**Redirect to**
abc.com/category5/post-about-fashion/
i am using wordpress. my permalink is /%category%/%postname%/. my htaccess code is below...
<IfModule mod_rewrite.c>
RewriteEngine On
# code by anubhava
RewriteCond %{QUERY_STRING} ^.+$
RewriteRule ^(page/[0-9]+/).*$ /$1? [L,NC,R=301]
# code by anubhava
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteCond %{HTTP_HOST} ^www\.deemasfashion\.com$
RewriteRule ^deemasfashion\.com/?(.*)$ http://deemasfashion.com/$1 [R=301,L]
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html\ HTTP/
RewriteRule ^index\.html$ http://deemasfashion.com/ [R=301,L]
RewriteRule ^index\.htm$ http://deemasfashion.com/ [R=301,L]
</IfModule>
I believe you need 2 additional rules:
RewriteCond %{QUERY_STRING} ^.+$
RewriteRule ^(page/[0-9]+/?).*$ /$1? [L,NC,R=301]
RewriteRule ^(category[0-9]+/[^/]+/?).+$ /$1? [L,NC,R=301]
RewriteCond %{QUERY_STRING} (?:^|&)post=([^&]+) [NC]
RewriteRule ^wp-admin/post\.php$ /?p=%1 [L,NC,R=301]
Make sure these are top 3 rules just below RewriteEngine On