Forum Moderators: phranque
I use mod_rewrite to create a virtual directory structure:
RewriteEngine on
# Add trailing slash if missing
RewriteCond $1 ^[^\.]+[^/]$
RewriteRule (.*) [%{HTTP_HOST}...] [R=301,L]
#
# Internally rewrite SEO-friendly URLs to script
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/$ index.php?m=$1&p=$2&s=$3 [L]
RewriteRule ^([^/]+)/([^/]+)/$ index.php?m=$1&p=$2 [L]
RewriteRule ^([^/]+)/$ index.php?m=$1 [L]
With the above rules, in order to relatively link, I have to insert the "../" when I want to go back up a level i.e. if the folder structure is example.com/section/products/ in order to link to a root folder directory I would have to use <a href="../../differentsection/products/"> otherwise without using the "../../" it would append it to the current url like this: example.com/section/products/differentsection/products
Now I have seem a number of other websites which work differently. i.e. if they were on page example.com/section/products they would simply use <a href="differentsection/products/">
I would really appreciate some help on this as it would save me hassle with lot's of things! (I currently use a loop function which add's the correct amount of "../"'s depending on current folder depth in url!)
Thanks!
Will
<a href="/<path>/differentsection/products/">
<a href="http://example.com/<path>/differentsection/products/">
Jim