Forum Moderators: phranque

Message Too Old, No Replies

Two RewriteConditions, One problem

Small rewritecond problem

         

asantos

12:28 am on Mar 14, 2006 (gmt 0)

10+ Year Member



So... this is my .htaccess:

RewriteEngine on
# Language
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*)/_([A-Za-z]{2})/?$ /index.php?l=$2 [L]
# Sections
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteRule ^(.*)$ /index.php [L]

That means:
www.mysite.com/about_us/employees/
goes to index.php

www.mysite.com/about_us/employees/_es
goes to index.php?l=es

The problem comes when i don't call any previous directories when calling a language:
www.mysite.com/_es

...it takes the second rewriteCond instead of the first one. help!

jdMorgan

12:47 am on Mar 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want to require exactly two subdirectory levels, you could use:

RewriteRule ^[^/]+/[^/]+/_([a-z]{2})/?$ /index.php?l=$1 [NC,L]

Alternately, you could specifically require the 'about_us' subdirectory prefix in the rule -- whatever makes sense for your site, and results in 'robust' detection using mod_rewrite patterns.

RewriteRule ^about_us/[^/]+/_([a-z]{2})/?$ /index.php?l=$1 [NC,L]

Jim

asantos

12:47 am on Mar 14, 2006 (gmt 0)

10+ Year Member



Mmm, i fixed by adding two rewriteconds for the language:

RewriteRule ^(_([A-Za-z]{2}))/?$ /personal/online/egobits/index.php?l=$2 [L]
RewriteRule ^(.*)/(_([A-Za-z]{2}))/?$ /personal/online/egobits/index.php?l=$2 [L]

is there a way to mix them together?