WordPress.org

Ready to get started?Download WordPress

Forums

htaccess and multiple WordPress installs (6 posts)

  1. archdata
    Member
    Posted 6 years ago #

    Before I start.

    I have looked, read, and digested all the documents about running WordPress in a sub-directory. I have searched this forum and Google for an answer to no avail. Here is my problem.

    I need to run two installs of WordPress. One is in a directory called 'en' the other in a directory called 'fr' (I think you may see where this is going).

    Using one install for English and one for French sprinkle some metadata juice and template hacking and I have the ability to run a multilingual site with links between the pages (no posts for this site just pages). The databases are separate (one english_site, the other french_site)

    Everything works as it should - but one problem - the url's

    We like clean URL's and have the site looks like this:

    http://www.example.com/en/page-name/

    What we would need is:

    http://www.example.com/page-name/

    The content of the site is duplicated in each individual install, but of course the page_names are different (English and French)

    All that said what I would love to do it take the usual htaccess file (with works fine and is created by WordPress) and just strip out/hide/remove the 'en' and 'fr' that appears in the URL. I have tried numerous solutions on this forum - with no results, just 404 pages.

    Any help would be appreciated. Thanks for the time.

    ArchDATA

  2. moshu
    Member
    Posted 6 years ago #

    With two separate installation I don't see any way for the desired solution.
    Just a note: you could have used a plugin (Gengo) to have a bilingual blog - although even in that case the permalinks would be
    example.com/page-slug/en and example.com/page-slug/fr

  3. archdata
    Member
    Posted 6 years ago #

    A few hours later and a possible solution.

    Because I know the name of all my top level pages what works is the following:

    Use the usual htaccess in the WordPress install directory (in this case 'en')
    
    In the root create a .htaccess like this
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/?(.*)$ /en/$1$2
    </IfModule>`

    This is just an example of the basic structure. What I do is this...

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(page-name1|page-name2|page-name3)/?(.*)$ /en/$1$2
    RewriteRule ^(page-name1-fr|page-name2-fr|page-name3)/?(.*)$ /fr/$1$2
    </IfModule>`

    Because I have only 5 or 6 top level pages (and everything else as a sub-page) this seems to work so far... Whether it holds up under the strain who knows, but so far so good. Any suggestions to make this better would be greatly appreciated. Again thanks for the time (and the forums!)

    ArchDATA

  4. Doodlebee
    Member
    Posted 6 years ago #

    Am I nuts, or are you trying to have 1 url for 2 different pages? I *think* that's what I'm reading here.

    You can't do that. You can't do it in plain, static HTML either. You can't even do that for two different files in one single directory (without overwriting the original file).

    If you have 2 different pages, then you must have 2 different URLs.

    Maybe I'm reading the question wrong, but that's what I'm seeing.

  5. archdata
    Member
    Posted 6 years ago #

    Well I won't comment on your mental state, but no I am not trying to have 1 url for 2 different pages. What I have is two separate installs for wordpress and I want to remove the install directory from the url (which I did and it seems to work).

    Bilingual sites are really hard to design and keep up to date, and there is not CMS out there that will do what a bilingual CMS should do. A bilingual blog is easy (use Gengo) but with a government site like the one I am building, everyting must be edited, translated, edited again and then passed through the intestine of a large bull elephant before it can be approved to go live. Because, there are no *real* solutions for a multilingual site (yes I know of software that will do it - but have you seen the code it produces... yuck)

    The setup that I am talking about solves out problem quite easily. One install for each language. Since I know the layout and page names for each and every page I can now rewrite the URL's as in my post above. Because speed is not essential - two installations opened in tabs in Firefox works just fine - and it allows me to change css and settings for the different languages (French words are always longer).

    That said - are there any other solutions out there for what I am doing? What I have now works - but always open to new ideas. Thanks.

    ArchDATA

  6. Doodlebee
    Member
    Posted 6 years ago #

    Well I won't comment on your mental state

    Wow, you're the first! LOL

    What I have is two separate installs for wordpress and I want to remove the install directory from the url (which I did and it seems to work).

    Ahhh...*now* I see. *That* makes sense.

    What I *do* know is that, if you have wordpress in it's own folder, you can remove the installation folder from the URL pretty easily. All you need to do is set the Blog URI (in your options area) as a different URL. Then you need to find your index.php file (in your WordPress installation) and move it to the URL directory you changed the Blog URI to. Then edit the path in the index.php file so it can find the wp-blog-header.php file. If you do this, the directory "goes away" - unless you're in the admin area. The public site won't have it. You, of course, have to edit your permalinks (which edits the .htaccess file), thus producing the same effect you've had.

    Hopefully that's what you're looking for (even though you got it working in another way!) :) it's up to you, though, to have them separated so that the index.php directory brings up the right version of the site (you can't exactly put *both* index.php files in the same directory...) - but I think you've got that covered.

Topic Closed

This topic has been closed to new replies.

About this Topic