I am trying to implement an htaccess redirect and it is partially working. It will redirect the root domain http://oldsite.com/ to http://newsite.com/. However, when I try and do more such as http://oldsite.com/eng it will not redirect. Here is my htaccess:
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newsite.com/$1 [R=301,L]
This is from a wordpress site that had two domains that pointed to the same folder on the server (same wordpress instance). We now want to phase out the old domain so whatever link you go to on http://oldsite.com/ will redirect to the correct part of http://newsite.com/.
You should try and check for the old host before doing the redirect. If it's on the same server it will cause problems without it.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www\.)?oldsite.com [NC]
RewriteRule ^(.*)$ http://www.newsite.com/$1 [R=301,L]
Related
I just added a new site to my wordpress multisite and if www wasnt in front of the url, it redirected to my main site.
i added the following code to my htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
and now my secondary site works just fine, however my main site now redirects to the secondary one.
does anyone have any suggestions for me?
thanks
Yours will rewrite any URL without www.example.com to the new domain.
This worked for me, to rewrite all non www to example.com.
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}/$1 [R=301,L]
Also, for some reason, I needed to refresh the permalinks in the child site as well.
my domain breaktagdigital.com needs to be redirected to https://breaktagdigital.com.au I already have this setup in my rewrite rules which does not seem to be redirecting the URL or any other pages, which it is also not allowing me to do within wordpress, force secure is on within cloudflare and I just turned it off in Ithemes:
RewriteCond %{HTTP_HOST} ^www.breaktagdigital.com.au [NC]
RewriteCond %{HTTP_HOST} ^breaktagdigital.com [NC]
RewriteRule ^(.*)$ https://breaktagdigital.com.au/$1 [L,R=301,NC]
if I add anything to this to try redirect breaktagdigital.com any further it breaks .com.au help please?
Should I be putting another if module in between wordpress and ithemes??
Based on your shown samples, could you please try following. This will redirect from www/non-www yoursite.com TO yoursite.com.au site. Please make sure to clear your browser cache before testing your URLs.
RewriteEngine ON
RewriteCond %{HTTP_HOST} ^(?:www\.)(breaktagdigital\.com) [NC]
RewriteRule ^ https://%1.au%{REQUEST_URI} [L,R=301,NE]
I have a Wordpress multisite with a primary domain that is used for admin site management and then hundreds of other sites that each have their own unique domain (NOT a subfolder or subdomain of the primary site).
I need to redirect each site to its corresponding landing page on our main site. I am programmatically generating these redirect rules since there are hundreds of redirects that need to be set up. I am then adding those redirect rules to one master .htaccess file at the document root.
Here is what I have so far:
RewriteCond %{HTTP_HOST} ^(.*)?firstsite.com [NC]
Redirect 301 / https://newsite.com/1234/
RewriteCond %{HTTP_HOST} ^(.*)?secondsite.com [NC]
Redirect 301 / https://newsite.com/5678/
What I'm seeing is that it is redirecting all traffic from any of the sites to the first "Redirect 301" address (https://newsite.com/1234/). Presumably because I'm doing "Redirect 301 /" which is redirecting the document root of the entire Wordpress multisite instead of the root of the "RewriteCond" domain specified.
How do I set up essentially a conditional redirect based on the domain being accessed?
I should mention that I do not have Nginx installed on the server.
RewriteCond and RewriteRule work together. So the Redirect 301 was running independently of the RewriteCond. This will work:
RewriteCond %{HTTP_HOST} ^(.*)?firstsite.com [NC]
RewriteRule ^(.*)$ https://newsite.com/1234/$1 [R=301,L]
RewriteCond %{HTTP_HOST} ^(.*)?secondsite.com [NC]
RewriteRule ^(.*)$ https://newsite.com/5678/$1 [R=301,L]
Also, be sure to place this at the very top of your .htaccess rewrite rules. Right underneath the line that says:
RewriteEngine On
I would like to redirect from non-https to https on my site and subdomains, but I'm having issues to solve it.
This is my setup:
www.domain.de
www.sub.domain.de
www.sub2.domain.de
www.sub3.domain.de
I can open all links by https and it works, but due duplicate content I would like to use https only.
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^(.*)$ https://domain.de/$1 [R=301,L]
this is my htaccess so far... but it redirects the subdomains to the primary domain :(
any ideas?
You can use:
RewriteEngine On
RewriteCond %{SERVER_PORT} !=443
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
You can use this pluging: https://wordpress.org/plugins/https-redirection/
It is a simpel way to do it, it redirect everything from HTTP to HTTPS.
I'm trying to figure out the best way to redirect a client site to a new blog. They have a Wordpress installation, which they want to redirect to a new Wordpress site. The issues are they want to redirect everything, but four posts, to the root of the new domain. The four posts have corresponding ones on the new blog, so
olddomain/setting-goals/ redirects to newdomain/setting-goals/
The same goes for three other posts, but I can't put them here due to reputation rules.
My issue comes in how can I do the redirect of four posts to their corresponding ones on the new domain and also redirect everything else (including home page) to the root of the new domain?
A caveat is they want to still be able to access their Wordpress admin panel on the old domain, so wp-login.php and the /wp-admin/ folder.
I tried this code in htaccess on top of the default Wordpress redirect, but it didn't work for me. I just wanted to see if I can get one of the redirects working correctly. It was just redirecting the setting-goals/ to the root of the new domain:
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/setting-goals/ [NC]
RewriteRule ^setting-goals/(.*)$ http://www.newdomain.com/$1 [L,R=301]
RewriteRule (.*) http://www.newdomain.com? [R=301,L]
You can use for 4 rules like below to redirect to their exact URL on the newdomain. Then redirect everything else if it's not wp-login.php or wp-admin.
RewriteEngine on
RewriteRule ^(setting-goals)/?$ http://www.newdomain.com/$1 [L,R=301]
RewriteRule ^(setting-goals2)/?$ http://www.newdomain.com/$1 [L,R=301]
RewriteRule ^(setting-goals3)/?$ http://www.newdomain.com/$1 [L,R=301]
RewriteRule ^(setting-goals4)/?$ http://www.newdomain.com/$1 [L,R=301]
RewriteCond %{REQUEST_URI} !^/(wp-login.php|wp-admin(.*)?)$
RewriteRule ^(.*)$ http://www.newdomain.com/? [R=301,L]