Forum Moderators: phranque

Message Too Old, No Replies

Conflict DETECTED!

Between .htaccess (virtual folders) and real folders...

         

omoutop

10:39 am on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hi to all!

I have a set of rules that work fine, for example:

RewriteRule ^(.*)/(.*)/hotels/(.*)-(.*).htm$ list_all.php?area=$1&island_name=$2&island_name=$3&tname=$4 [nc]
RewriteRule ^(.*)/(.*)/hotels/(.*)-(.*)-category-(.*).htm$ list_category.php?area=$1&island_name=$2&island_name=$3&tname=$4&cat_name=$5 [nc]
RewriteRule ^(.*)/(.*)/hotels/(.*)-(.*)-category.htm$ list_category.php?area=$1&island_name=$2&island_name=$3&tname=$4 [nc]
RewriteRule ^(.*)/(.*)/hotels/(.*)-(.*)-villages.htm$ list_location.php?area=$1&island_name=$2&island_name=$3&tname=$4 [nc]

these can be translated to:

www.mysite.com/cyclades/naxos/hotels/naxos-hotels.htm (for first rule)
www.mysite.com/cyclades/naxos/hotels/naxos-hotels-category-A.htm (for second rule)...and so on and so forth....all these folders (cyclads, naxos etc) are virtual and created by .htaccess...However, if I go to my root folder and create these folders manually i.e. cyclades/naxos everything falls apart...most of my dynamic pages do not work, the thing is that I have a site that needs the static folders and pages for a reason, as well as the dynamic along with the htaccess for another reason....is this conflict logical?

Thx in advance, I hope there is a way!

jd01

11:35 am on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would think with the catch-alls you are using it would be the other way around and you would not be able to access the static pages , but the dynamic should still work (maybe I am reading something wrong)... did you upload an .htaccess file to the directory you created?

There are some efficiency corrections you could make in your rules too:

RewriteRule ^([^/]+)/([^/]+)/hotels/([^-]+)-([^.]+)\.htm$ list_all.php?area=$1&island_name=$2&island_name=$3&tname=$4 [NC,L]

Forward-looking regular expressions are *much* less processor intensive than the standard .* --- so the above says:

'anything not a / followed by a / followed by anything not a / followed by /hotels/ followed by anything not a - followed by a - followed by anything not a .(dot) followed by a litteral .(dot) followed by htm'

I also escaped the meta dot (anything except the end of a line) to match a true .(dot) and added the L (last) flag, which will save some additional cycles of processing --- If the L flag is missing, the request will be tested against all rules, not only the one it matches.

Not sure about the first question, because I am not sure I understand correctly what is happening.

Hope this helps.

Justin

omoutop

12:10 pm on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



thanks for tips on improving performance.....

let me be more specific for my problem

I have the folowing root structure:
{folder1}
{folder2}
file.php
and the htaccess rule is
RewriteRule ^([^/]+)/([^/]+)/hotels/([^/]+)-([^/]+)-category\.htm$ file.php?area=$1&island_name=$2&island_name=$3&tname=$4 [NC,L]

so this will give me : www.site.com/area/island/hotels/island-hotels-category.htm

IF i add the folder {area} in the root folder (where the file.php is), the htaccess rule dont work
** it coniders the ([^/]+)-([^/]+) part as one (1) variable, thus not being able to query my db.

IF i use (_) insted of (-) in rule (and in links in page), the htaccess rule works fine giving me
www.site.com/area/island/hotels/island_hotels_category.htm

Any ideas on what the problem may be?

jdMorgan

12:38 pm on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



See RewriteOptions [httpd.apache.org] inherit.

Your server default is probably set to 'off', so subdirectories (if they exist) do not inherit the rules of their parent directories.

Jim

omoutop

1:02 pm on Jan 12, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



in case i dont have access to server, how can i manually "force" my rules?

I used RewriteOptions inherit in htaccess (right below RewriteEngine On) to no avail....

i am a little confuced here!

*. Should i use RewriteCond along with RewriteRule in any rule i wish to apply?