Two WordPress Multisite installation in different subdirectories - wordpress

I have a WordPress Multisite installation here: mydomain.com
I use it to have different languages like:
mydomain.com/fr
mydomain.com/de
...
Now we are changing design, but we would like to do step by step, language by language.
So we have installed another Wordpress Multisite in the folder /new, that it's working perfectly with sites like
mydomain.com/new/fr
mydomain.com/new/de
...
We would like to redirect JUST THE FRENCH language to the new wordpress. I've tried with this .htaccess in the root folder (based on the information in Wordpress documentation:
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteCond %{REQUEST_URI} !^/fr/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^fr(.*)$ /new/fr/$1
RewriteCond %{HTTP_HOST} ^mydomain.com$
RewriteRule ^fr(/)?$ /new/fr/index.php [L]
But that is giving a "Error establishing a database connection". It's weird because, as I explained, the site mydomain.com/new/fr is working perfectly.
NOTE: we don't want to use subdomains, I know that would make a different approach and solution ;-)
EDIT: The error is because this query
SELECT blog_id FROM wp_blogs WHERE domain IN ( 'mydomain.com' ) AND path IN ( '/fr/', '/' ) ORDER BY CHAR_LENGTH(path) DESC LIMIT 1
I guess, the redirection is working well, but when the wordpress inside "new" directory tries to determine which blog to visit, it reads the URL and it's in "/" really, since the redirection rule has an [L] and keeps the original URL in the apache environment variables.

If you activated Multisite on WordPress 3.5 or later, you can follow the documentation setup in the section .htaccess and Mod Rewrite
According to the documentation:
.htaccess and Mod Rewrite Unlike Single Site WordPress, which can work
with "ugly" Permalinks and thus does not need Mod Rewrite, MultiSite
requires its use to format URLs for your subsites. This necessitates
the use of an .htaccess file, the format of which will be slightly
different if you're using SubFolders or SubDomains. The examples below
are the standard .htaccess entries for WordPress SubFolders and
SubDomains, when WordPress is installed in the root folder of your
website. If you have WordPress in its own folder, you will need to
change the value for RewriteBase appropriately.

Related

Fishpig Wordpress Magento - http://example.com/blog resolves to www.example.com rather than www.example.com/blog

I have a working Fishpig Wordpress Magento instance on a production server.
All the green ticks show it has succesfully configured and when visiting
http://www.example.com/blog
it works. However when I try and and visit
http://example.com/blog
it sends me back to the magento home page at www.example.com .
I have tried setting the url in wordpress to both http://example.com/blog and http://www.example.com/blog but in both situations it always sends me to the home page at site.com.
This is a concern because most experienced web users will not type www when trying to access a location.
My htaccess is as generated by Wordpress and looks like
DirectoryIndex index.html index.php
<IfModule mod_rewrite.c>
#wp generated
RewriteEngine On
RewriteBase /blog/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Please not the wordpress site files are located at site.com/wp and it is the fishpig extension which arranges the direct from the non existent /blog path.
First of all, to start of, one way to resolve the issue is to simply make your Magento website DEFAULT to not have the www. in the url.
In Magento, go to System > Configuration > Web.
In the "Secure" and "Unsecure" tabs, find "Base URL."
The value should look something like this:
http://www.site.com/
Replace ALL references to the domain so it shows:
http://site.com/
Unfortunately, there may be a lot of appearances of it throughout the site. You'll need to do the same thing elsewhere on the server.
If you really want your site/blog to say www., though, you'll have to properly forward the .htaccess file in Magento. I'm not too keen on how Magento's .htaccess file works, but I do know how to forward a url and keep all of its additional pages as well (however, Magento's setup may interfere).
The code should look something like this:
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^site.com$ [NC,OR]
RewriteRule ^(.*)$ http://www.site.com$1 [R=301,L]
Again, I don't know how well this will work with Magento's set up, but I've successfully used the above code to redirect url's to the correct url I want. That code above was actually used on a wordpress site, though.
Check for Rewrite rules in Magento's .htaccess file and try putting this above it. Be careful, though; it is VERY easy to cause 500 internal server errors if you mess up the .htaccess file, so always keep a backup.
Try this out and I hope it helps.

Migrating Wordpress blog from www.site.com to newdomain.com/blog

I am planning on migrating a blog that is currently hosted at
www.blog.com
to a subdirectory in a new domain such as
newdomain.com/blog
So far I've seen several tips on how doing this and [in particular from Yoast (Joost) is helpful but not identical to my situation 1.
Any suggestions?
The main steps on Joost's article are as follows:
[1 ] Edit wp-config.php
define('WP_SITEURL', 'http://www.newdomain.com');
define('WP_HOME', 'http://www.newdomain.com');
[2 ] Use the Search and Replace plugin to replace old URLs
[3 ] Update .htaccess to
Redirect 301 /blog/ http://www.newdomain.com/ // <== note this is NOT my situation
// I likely need the reverse
However, this won't address my particular need, in which a different change in .htaccess and wp-config.php may be necessary.
Any suggestions?
Wordpress has some RewriteRules that it wants to use in an .htaccess file. It should look something like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I think that all you need to do is take this and place it in an .htaccess file in your document root (where http://www.newdomain.com/ is). If you don't have any special rewrite rules or options in your .htaccess file, you could just move the file out of /blog/ and into /. You don't want these rules in both places.
Then in wordpress' admin panel (you'll need to go here: http://www.newdomain.com/blog/wp-admin/options-general.php ) there are 2 fields, one for WordPress address (URL) (this should say http://www.newdomain.com/blog/ ) and one for Site address (URL) (this should say http://www.newdomain.com/ ). And I think that's all you need to do.
If you are using custom themes you may want to double check any absolute URIs you have in the headers/footers/etc.
There's some more information about doing this here: Giving Wordpress It's Own Directory
EDIT: I forgot to mention that you need to create an index.php in your document root. In the link above, under the section Using a pre-existing subdirectory install, you need to follow the steps to create an index.php. You only need 2 lines.
As for the code-igniter/wordpress conflict. You may need to get the 2 rules to jive with each other, and that may not be so easy to do. You either have to move code-igniter's rules into their own directory or use RewriteCond to make sure they don't step on each other. For example, adding a RewriteCond !/index.php so wordpress' rewritten URI won't get re-rewritten by code-igniter's.
I would suggest a clean install. Just export your blog posts as XML, and copy over the uploads.

Wordpress + multilingual plugin (qtranslate) will not show the translation when switching languages

the problem I have with the multilingual plugin (qTranslate), is that it won't switch to another language it gives me 404 when trying to switch the language of posts.
This can be a result of either:
* WordPress is installed in a directory (not root) and you're using default links.
* URL rewriting is not enabled in your web server.
* The web server cannot write to the .htaccess file
I have my htaccess file with 644 and the following code is in there:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
And I'm using a custom permalinks structure: /%category%/%postname%/
but I still have 404 when trying to switch language.
anybody knows what else could be adffecting the translation plugin?
i don't know if this can help, but i had a kind of similar issue, only with the search results. with method get it was working fine for the main language, but english made 404, with method post for english, and german went to the home-page.
then i changed the url in the wp general settings from abc.com/def to abc.com (i had the directory in both fields and removed it from both). wp is not in www, but www-directory is redirected to the wp-folder. so the subdir was not necessary anymore (had it put for development). and, don't know why, but after this, the post method-search worked well like described in the wp-forum ( http://www.qianqin.de/qtranslate/forum/ ) where you can find lots of useful tips for qtranslate issues. also applying the gettext might help: http://www.qianqin.de/qtranslate/forum/viewtopic.php?f=3&t=294&sid=5be0c994e226ab99b5bed7c28a250bab
hope this helps.

Wordpress installed in root folder, subdomain now not working, GoDaddy host

please forgive me for being a complete beginner at this, I'd rather not have to try to deal with this myself but as GoDaddy support have not replied after 2 days I'm going to have to. I think my problem is the same as the one above, but I'm not 100% sure, so I'm reposting it, I'm not really confident enough to attempt to try the fixes I've seen here so I need someone to give me baby instructions?
Our original website (www.mwpics.com.au) was built in Dreamweaver etc, recently we created a new website in Wordpress, in a subdomain, then migrated it over to the root folder where it is now operating fine. I also moved the files for the old website into another directory which I called 'old', so they're all still there.
The problem is that I have a subdomain set up - which is still showing as set up in the control panel on godaddy the url is www.mwpics.com.au/clients and it is at www.clients.mwpics.com.au. This directory contains loads of other directories, each of which is password protected by .htaccess files and which our clients access directly (not through the site) to download their finished work. The test one and the one for random clients is www.mwpics.com.au/clients/temp - username and password both temp (the usernames are all the same as the directory names).
Since the WP install to the root directory the /clients extension no longer works (it should bring up an information page which is an .html index page in the directory) and the /clients/name extensions no longer works - it goes back to the wp site with a 'not found' error message. Strangely it does bring up the box for the username and password, but when you enter it it just goes back to the 'not found' message.
Someone told me it was the .htaccess file - so as an experiment, I renamed the .htaccess file in the root directory and then copied the .htaccess file from the old root files into the root directory, eureka! It worked - and also the WP site opened to the home page... but bummer - the /pages in the WP site now no longer worked! But at least I know the source of the problem.
So I switched it back and this is the status quo - I have no idea how to fix this, and with everyone back at work tomorrow, clients are going to want to start downloading their stuff...
Can anyone help me? I'm starting to panic a bit
you only have to exclude the clients subfolder in your wordpress .htaccess - see .htaccess & Wordpress: Exclude folder from RewriteRule for a detailed description
this should work:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^/clients.*
RewriteCond %{SERVER_NAME} !clients\.yourdomain\.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
short: it simply skips the wordpress rewrite rule if the reqest uri starts with /clients or the domain name is clients.yourdomain.com
be aware though, that as soon as you update your wordpress permalink settings, this rule will be overwritten by wordpress ...
Try adding the following at the top of your root directory's .htaccess file, before the WP code block:
<IfModule mod_rewrite.c>
# fix rewrite for GoDaddy
Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} clients.mwpics.com.au$ [NC,OR] # ignore subdomain
RewriteCond %{REQUEST_FILENAME} -d [NC] # ignore directories
RewriteRule .* - [L]
</IfModule>

Using .htaccess to redirect if file isn't found with Wordpress

I have an issue where we are merging a website with Wordpress. The website has a ton of news stories in a "/news" directory that we need to keep. When we add the CMS at say "/wordpress" we can set the base URL to the root of the directory so when we make a new post in the category "news", the link for it is "/news/this-is-the-post-title", except the REAL location is "/wordpress/news/this-is-the-post-title". So my issue is that we want to keep all news stories at the "/news" URL, and in my head we just need the .htaccess to say "if the requested URL doesn't exist in the /news directory, try /wordpress/news", and of course if Wordpress doesn't find anything, it can 404. Hope this makes sense, thank you!
I don't fully understand how the original news stories are held. But, if they are grabbed with PHP then you should be able to redirect to /wordpress/news/post-title if it doesn't exist.
On the other hand, if the news stories are static files you can check for them with .htaccess and make sure the file exists on the server.
# Goes in the "news" directory
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /news
# These make sure the file or directory doesn't exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Redirect to /wordpress/news/whatever-entered-goes-here
RewriteRule ^(.*)$ /wordpress/news/$1 [L]
</IfModule>
Reference: http://www.addedbytes.com/cheat-sheets/mod_rewrite-cheat-sheet/
If you only use WordPress and static pre-existing directories and files (and not another CMS, next to WordPress), you can probably just follow the directions on giving WordPress its own directory. All WordPress files go to wordpress/, only the index.php and .htaccess are copied back to the root directory. The standard .htaccess from WordPress already has the two RewriteCond rules that check for existing files, so if the request is for news/happy-2010.html and this file already exists, your server will just serve this and not start WordPress.

Resources