Forum Moderators: phranque
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!
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
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?
Your server default is probably set to 'off', so subdirectories (if they exist) do not inherit the rules of their parent directories.
Jim