.htaccess wordpress multisite redirect between subsites - wordpress

I am building a new site for a client. we preserved the old site in a wordpress multisitesolution. Now it's time to migrate into the new site. Problem is the old site is heavilly embedded in Google Search with many active links. So I need a way to catch and redirect each and every link that comes our way.
I can redirect old.sitename.com to new.sitename.com directly - this works fine. Problem is when I get direct links to posts or pages.
Som this is the syntax I need resolved
old.sitename.com/an-article-read-this --> new.sitename.com/an-article-read-this
I have tried several .htaccess commands, including a few wordpress addons. Even simple ssl with .htaccess redirect enabled.
RewriteRule ^old.*$\% https://hoppla.heiledeg.no/%{REQUEST_URI} [R=302,NC]
direct links keeps opening up in the old site. not the new one.
Yes I have refreshed cache. And even tested on "fresh" browsers.
Any ideas, tips, or even addons are very much appreciated.

for me this was the solution:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(old.)?olddomain.com$ [NC]
RewriteRule ^(.*)$ http://www.newdomain.com/$1 [L,R=301]

Related

Redirect To A Custom Url Depending on Location on wordpress with parameters

I need to redirect my store customers to another clone installation in a sub-directory.
For Example:
A US visitor can visit: ‘example.com/product’
When a Canadian visitor visits the same link, it should redirect to: ‘example.com/ca/product’
I have tried out a few geo redirection plugins but the issue is as follows:
The redirection goes to ‘example.com/ca’ and the ‘product’ part is left out.
Any fixes?
NOTE: I have a clone installation of ‘example.com’ on ‘example.com/ca’.
I didn't need such a comprehensive multilingual plugin setup in my wordpress installation. So I have just used multi-site and added this to my htaccess file to redirect users to my 'irish' site based upon browser language config:
RewriteCond %{HTTP:Accept-Language} ^ie [NC]
RewriteCond %{REQUEST_URI} !ie [NC]
RewriteRule ^(.*)$ https://yoursite.com/ie [L,R=301]
I hope this is a quick and easy fix for someone. As I tried doing an action in functions.php and kept going around in circles for an hour!
You should use the plugin WPML for multilanguge. With this plugin you can use the option redirect by language WPML > Languages > Redirection according to browser language. I have it set up like this in a website of mine and it works fine.
If you want do it trought IP, you will need to add some more work. Im sending you info, I hope it is useful for you:
https://wpml.org/forums/topic/autoselect-native-language/#post-284007
http://wordpress.org/plugins/geographical-redirect/
https://wpml.org/forums/topic/how-to-detect-ip-location-and-automatically-display-local-language/

Wordpress Home page URL changing to /?i=1 - issue

When I try to access my Wordpress website directly or from google, the Home page URL automatically adding /?i=1 and sometimes /?i=2 to the URL in the address bar.
I think it's a very simple to solve it, but I tried many things and didn't work.
So I wonder how can I solve this to be only the URL without /?i=1 or /?i=2 ?
/?i=1 or /?i=2 protects your website from bots and is mostly applied by free hosting services and if you use any .htaccess code to remove it than all ? parameters will removed and redirect you to homepage
Try resetting your wordpress permalink from admin end. If you don't know how to do that check this video. As this is not normal behavior of wordpress you can also check your .htaccess file.
RewriteCond %{QUERY_STRING} ^(.*)i=[^&]+(.*)$ [NC]
RewriteRule ^(.*)$ /$1?%1%2 [R=301,L]
Add this in htaccess

Redirect one specific Wordpress URL to another site for mobile users in htaccess

Need some syntax help if someone would be so kind. I have one page on my Wordpress site (http://www.thisweekonmv.com/vineyard-map) that I need to redirect to another website's URL for mobile users only. I would like to do this in .htaccess, but so far all of the solutions I've researched online haven't worked.
This is what I have that isn't working...I probably am close but something is definitely wrong?
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|operamobile|palmos|webos|googlebot-mobile" [nc]
rewriterule ^vineyard-map(.*)$ http://myatlascms.com/map/?id=938$1 [r=301,nc]
Refer this links
https://wordpress.org/support/topic/how-to-redirect-links-for-mobile-using-htaccess
Mobile Redirect using htaccess

Mixed content - SSL http/https issue

Approximately 2 months ago I installed a SSL certificate on my site, catherinerushforth.com. I changed the site and WordPress URL in the admin area of WordPress to include https:// instead of http://. All was fine.
Then, about 2 weeks ago I started to have a problem with "Mixed Content" errors on all pages except the main home page. There doesn't seem to be an issue when viewing the site with Safari but there is a problem with Chrome, Firefox and Internet Explorer. I inspected the Javascript console in Chrome (as an example) and saw multiple "Mixed Content" errors
This is what I have do so far to try and fix these mixed content errors:
Changed http:// to https:// in the WordPress Admin section for the site and WordPress URLs (Settings/General)
I've added "define('FORCE_SSL_ADMIN', true);" to the top of the wp-config.php file.
I've added the following piece of code to the .htaccess file:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^catherinerushforth.com [NC]
RewriteRule ^(.*)$ https://catherinerushforth.com/$1 [L,R=301]
With this code I get "ERR_TOO_MANY_REDIRECTS"
I've also tried the plugin, WordPress HTTPS (SSL).
None of the above have worked.
Does anyone know what I am doing wrong and/or have any suggestions as to how I can fixed this issue?
Many thanks.
WordPress version: 4.2.2
Theme: X-theme v.4 (although issue was the same in previous version of this theme)
Site: catherinerushforth.com
UPDATE
If I simply remade each page for my site (which I will probably have to do at some point due to X-Theme now using their CornerStone page builder) would this ensure all links were https:// and not http://?
Remove
define('FORCE_SSL_ADMIN', true);
from wp-config.php, be sure you have changed http:// to https:// in WordPress Admin, and then force SSL for front and backends with this in .htaccess above the WordPress rewrite block:
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://catherinerushforth.com/$1 [R=301,L]
That only forces SSL; you still need to find the site resources which are loading non-SSL.
So use the developer tools in Firefox (or Firebug) or Chrome or Safari or IE to see the errors with specific site resources.
And:
• you should change URLs of media items and links in the post/page content to https so they don't depend on the redirect in .htaccess. Search RegEx is a good plugin to be able to search and replace (optionally with grep) through all posts, pages, excerpts, comments, titles and meta. And, interconnectit.com WordPress Serialized PHP Search Replace Tool can be used to find/replace in the entire database, i.e. metadata, GUIDs and widget content, etc.
• You may need to change to a relative path for images in CSS files, i.e. background-image: url(http://example.com/themes/wp-content/theme/images/image.jpg) to background-image: url(images/image.jpg)
• You may need to remove the http from absolute paths in php theme files, i.e. change 'http://example.com/image.jpg' to '//example.com/image.jpg'; that will allow your resources to default to https.
RewriteEngine On
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
Source
So I had this issue on image urls being returned as http://https://website.com/image.jpg. What I did was use the Velvet URL plugin to rewrite the urls for all content from http://https://websiteurl to https://websiteurl. This fixed the issue for me. Cheers
Using ubuntu 16.04, letsencrypt, nginx, apache2, wordpress. For me
1. adding redirect in `/etc/apache2/sites-enabled/000-default.conf` didn't work (too many redirects)
2. adding RewriteRule in .htaccess didn't work (too many redirects)
Finally I installed really-simple-ssl plugin from wordpress and it worked like charm.

Redirect old domain to subdirectory of new domain via htaccess

I have a Wordpress blog running on Apache, which I am moving on to another wordpress site. On the new site, the blog will be in a subdirectory, with its URL structure intact.
I would like to redirect all traffic from pages of the old blog to the corresponding page within the subdirectory of the new site.
This is what I have so far. It is working to redirect the root of the blog to the subdirectory of the new site, but posts on the blog are not working - the page just hangs for a few minutes and then displays the blog without any css.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^blogname.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.newsite.com$
RewriteRule (.*)$ http://newsite.com/blogname/$1 [R=301,L]
</IfModule>
EDIT: More detail on the error:
blogname.com redirects successfully to http://newsite.com/blogname/ . However, if I go to blogname.com/page-name/ then the page takes several minutes to load. At the bottom of the screen it says "Waiting for newsite.com..., transferring data from newsite.com ". When the page eventually loads, it is blogname.com/page-name (hasn't redirected) , but the style/javascript hasn't loaded, because those files are redirecting.
Any help gratefully appreciated.
I discovered this problem was caused by the Wordpress plugin "FV Top Level Categories". I've disabled that and now the above redirect is working fine.
Thanks to all who offered help.

Resources