Forum Moderators: phranque

Message Too Old, No Replies

htaccess for a specific directory - struggling!

htaccess for a specific directory

         

Brady

5:17 am on Jan 11, 2008 (gmt 0)

10+ Year Member



Hello,

I'm new to htaccess and have been working a this problem forever. I have a htaccess file which handles my ecommerce store urls and redirects. I need my wordpress directory not to be affected by the rules listed below. Any help would be very appreciated. Thank you!

DirectoryIndex /mm5/merchant.mvc

RewriteEngine On
RewriteCond %{REQUEST_URI} ^/p/(.*)/(.*)[NC]
RewriteRule (.*) /mm5/merchant.mvc?Screen=PROD&Product_Code=%1&Category_Code=&Store_Code=DCS [L]
RewriteCond %{REQUEST_URI} ^/pc/(.*)/(.*)/(.*)[NC]
RewriteRule (.*) /mm5/merchant.mvc?Screen=PROD&Product_Code=%1&Category_Code=%2&Store_Code=DCS [L]
RewriteCond %{REQUEST_URI} ^/c/(.*)/(.*)[NC]
RewriteRule (.*) /mm5/merchant.mvc?Screen=CTGY&Category_Code=%1&Store_Code=DCS [L]

RewriteCond %{HTTP_HOST} ^(www\.)?example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com [R=301,L]

[edited by: jdMorgan at 3:41 pm (utc) on Jan. 11, 2008]
[edit reason] example.com [/edit]

jdMorgan

3:54 pm on Jan 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is this code located in a subdirectory below the .htaccess file that rewrites requests to WordPress?

If so, then the "standard" WordPress code should always run first, and this code should never be invoked, because the WordPress code basically rewrites *all* incoming requests to WordPress unless the requested URL resolves directly (without rewriting) to an existing physical file.

If that is the case, you will need to move these MM rules into the same .htaccess file as the WP rule, and modify them to suit. The MM5 rules will need to be placed before the WP rules so that the two sets don't interfere with each other.

We'll need more information about all of your .htaccess files and rules, and also about your directory structure, before proceeding.

Note also that your rules can be simplified and shortened. The RewriteConds are not required. For example, your first rule can be re-written as:


RewriteRule ^p/([^/]+)/(.*)$ /mm5/merchant.mvc?Screen=PROD&Product_Code=$1&Category_Code=&Store_Code=DCS [NC,L]

This will not affect your current problem, but has several tweaks that greatly improve efficiency. Note particularly the use of the negative-match first subpattern instead of ".*" -- an easy but inefficient method.

Jim

Brady

6:51 pm on Jan 11, 2008 (gmt 0)

10+ Year Member



Yes the .htaccess (code posted) is located in the root. The wordpress is a subdirectory of the root.

Wordpress didn't have it's own htaccess so I created one (which is currently blank).

The place where I get hung up is once I have the same rules in the wordpress file I don't know how to "modify them to suit".

directory structure:
root (main htaccess file lives here)
-wordpress

All the code in the main htacess has been posted in this post.

I hope I provided the info you needed.

Thanks very much for the help.

Brady

jdMorgan

11:21 pm on Jan 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I may be daft, but I don't see any rules for your Wordpress install...

Jim

Brady

11:45 pm on Jan 11, 2008 (gmt 0)

10+ Year Member



Sorry. Do you mean rules that exist in a htaccess file in the wordpress directory?

There was none. I created my own. In the one I created I tried turning rewrite off and commenting out rules and that didn't.

My apologizes if I'm not giving you the info you're looking for.

Currently it's blank.

jdMorgan

11:52 pm on Jan 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In most cases, Wordpress installs a badly-written rewriterule in /.htaccess. I don't see that code.

Where are you in this project? Did you have Wordpress working before or is this a new install? Did you perhaps overwrite the .htaccess file it generated? How about Miva -- is that new or did you have it working before?

One of the problems here is that we literally don't know anything about your site and server unless you write about it -- That's just part of the nature of this (or any) forum, but feel free to tell us as much as you can (without specifics that might identify your site to friend or foe). ;)

Jim

Brady

2:49 am on Jan 12, 2008 (gmt 0)

10+ Year Member



Hi,

I've looked through my directories for another htacess file associated with wordpress and I'm not finding anything. I un-installed and reinstalled and still didn't have one.

It's a new install. Wordpress is working, but because of my redirects for miva dynamic content urls redirect to my miva ecommerce store.

I've had Miva running for around a year now with the current htaccess code I provided with my post.

Thank you,

Brady

[edited by: tedster at 4:14 am (utc) on Jan. 12, 2008]
[edit reason] no personal urls, thanks [/edit]

jdMorgan

11:45 pm on Jan 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You will need to 'tell' mod_rewrite how to know the difference between a WP URL and an MM URL, then.

One way to do it is to put WP in a special subdirectory, or put MM is a subdirectory, or both. In this way, mod_rewrite can examine the requested URL-path, e.g. /mm/<something> or /wp/<something>, and rewrite the requests accordingly.

Another way to do it is to put each of them in their own subdomain IF your host supports this and IF you can set up your DNS so the subdomains resolve to the server.

Without something to tell mod_rewrite which resource a requested URL is intended for --your blog or your cart-- then it's simply going to rewrite all request to one or the other, depending on what rule comes first.

Jim