homepage Welcome to WebmasterWorld Guest from 54.205.241.107
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
URL redirecting messed up (WordPress & Opencart)
Presumably an .htaccess issue but can't figure out what
oc2ps



 
Msg#: 4550413 posted 1:56 pm on Mar 2, 2013 (gmt 0)

I need your help with something that has me flummoxed.

I have WordPress installed in domain root (www.rxample.com) and OpenCart in a subfolder (www.example.com/shop/).

Both installations are multilingual (WP is multilingual via WPML).

Deployed OpenCart SEO URLs in core program, and Multilingual SEO URL Bundle plugin for OpenCart.

The multilingual plugin for Opencart creates beautiful URLs like www.example.com/shop/hu/ingyen-e-book which mostly work very well.

However, the OpenCart root for Hungarian language (our primary language) does not. www.example.com/shop/hu/ redirects me to www.example.com/rolunk/husegprogram/ which is a WordPress page.

I should note at this point that:
  • English shop root works fine www.example.com/shop/en/
  • If I change the slug of husegprogram to something that doesn't start with hu, then I get a 404.
  • RewriteBase is correct in the OC .htaccess and there is no mention of hu in WP .htaccess


I'm totally at a loss here, and would greatly appreciate some help.

Using
  • WordPress 3.5.1
  • OpenCart 1.5.4.1 with vQmod 2.3.0

(just to clarify, there is no integration between WordPress and OpenCart)

[edited by: incrediBILL at 8:51 pm (utc) on Mar 2, 2013]
[edit reason] Use Example.com per Forum Charter [/edit]

 

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4550413 posted 7:44 pm on Mar 2, 2013 (gmt 0)

welcome to WebmasterWorld, oc2ps!

do you have any mod_rewrite directives in your .htaccess file that are relevant to this problem?
if you post what you find, please use example.com for your domain.

oc2ps



 
Msg#: 4550413 posted 8:37 am on Mar 3, 2013 (gmt 0)

Thanks phranque

For WordPress it is
# 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


For OpenCart it is
RewriteEngine On
RewriteBase /shop
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)\?*$ index.php?_route_=$1 [L,QSA]

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4550413 posted 9:28 am on Mar 3, 2013 (gmt 0)

^(.*)\?*$ is supposed to match what example URLs?
The \?* should be completely redundant as RewriteRule RegEx cannot match query strings, only paths.

You have . in one ruleset and this matches requests for any folder or file except root example.com/

You have .* in the other and this matches requests for any folder or file including root.

I assume you should add an exclusion to the Wordpress code to shop it trying to grab requests for OpenCart URLs.

Detete the ifModule start and end tags. You don't need them.

oc2ps



 
Msg#: 4550413 posted 10:46 am on Mar 3, 2013 (gmt 0)

I assume you should add an exclusion to the Wordpress code to shop it trying to grab requests for OpenCart URLs.

Thanks! Please can you guide me? I'm pretty much a newbie.

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4550413 posted 10:51 am on Mar 3, 2013 (gmt 0)

Delete the ifModule start and end tags. You don't need them.

And once you've done that, you can also delete the second
RewriteEngine On
line ... Unless you're quoting two different htaccess files in two different directories, both using mod_rewrite. If so, you are in deep ###. We just finished hashing out something similar a few days ago. (Short version: Don't even try. It isn't worth the aggravation.)

RewriteBase /shop

Doesn't a RewriteBase need a trailing slash? Probably a hypothetical question since I seriously doubt you can change RewriteBases in midstream. Luckily you don't need one; it's safer to write it out explicitly, starting with / for domain root each time.

The single most important thing to remember about htaccess is this: An incoming request doesn't teleport straight to the directory it lives in. Everything has to pass through all the layers of config file and root-level htaccess and inner-directory htaccesses. So you don't really have a "WordPress htaccess" and an "OpenCart htaccess". What you have is one htaccess that is used by everyone, and then a second htaccess that is only used by some things.

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4550413 posted 11:24 am on Mar 3, 2013 (gmt 0)

What you have is one htaccess that is used by everyone, and then a second htaccess that is only used by some things.

That's the most important point here.

oc2ps



 
Msg#: 4550413 posted 11:29 am on Mar 3, 2013 (gmt 0)

Unless you're quoting two different htaccess files in two different directories, both using mod_rewrite.

That seems to indeed be the case.

The root folder has the WordPress .htaccess

The /shop folder which is home to OpenCart has the OpenCart .htaccess

g1smd

WebmasterWorld Senior Member g1smd us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4550413 posted 1:40 pm on Mar 3, 2013 (gmt 0)

The Wordpress htaccess needs to exclude OpenCart URLs.

oc2ps



 
Msg#: 4550413 posted 2:16 pm on Mar 3, 2013 (gmt 0)

The Wordpress htaccess needs to exclude OpenCart URLs.

How? How do I put in the exclusions?

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4550413 posted 5:49 pm on Mar 3, 2013 (gmt 0)

use a RewriteCond directive.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved