...

View Full Version : mod_rewrite relative paths issue



JayStang
08-26-2006, 03:57 AM
Hey guys,
I wasn't sure if this should be in the php forums or html/css.

I'm using mod_rewrite to create some fake directories. Basically i run a CMS so all of my sites are dynamic. The way i use to do everything was just passing url variables... example... index.php?page=about

Now i'm using the mod_rewrite so that i can specify more like index.php/about

my problem is its throwing off all my relative paths for images and stylesheets. i thought i would just be able to reference in by the root...
example: insead of images/test.jpg i figured i could do /images/test.jpg and everything would be ok....

well i was wrong.. for some reason it doesn't want to reference to the root.... and even worse... i can get it to work it i add "../" in front of everything (not that i really want to) but when i do that say i add a second directory (index.php/about/sub) then i would need a "../../" to get that page to work... any thoughts?

thanks!

JayStang
08-26-2006, 05:25 AM
nevermind this thread... stupid mistake on my part... i forgot that i wasn't in the root directory.... i just had it in a folder on my server for testing.

musher
08-26-2006, 06:42 AM
Hey JayStang or any one else I trying to do the same thing
Basically i run a CMS so all of my sites are dynamic. The way i use to do everything was just passing url variables... example... index.php?page=about my example is a bit different

/index.php?section=About Us&subsection=Web Philosophy
which shows up as
index.php?section=About%20Us&subsection=Web%20Philosophy

I tried to set things up to use mod-rewrite the other day couldn't get it to work. I created a .htaccess file uploaded to httpdocs folder (here's what I put in the file



Options +FollowSymLinks

RewriteEngine on

RewriteRule ^home/?$ /index.php?section=Home&subsection=Home [L]
RewriteRule ^home/site-map/?$ /index.php?section=Home&subsection=Site%20Map [L]
RewriteRule ^about-us/?$ /index.php?section=About%20Us&subsection=About%20Us [L]
RewriteRule ^about-us/web-philosophy/?$ /index.php?section=About%20Us&subsection=Web%20Philosophy [L]
RewriteRule ^about-us/whats-a-sms/?$ /index.php?section=About%20Us&subsection=Whats%20an%20SMS [L]
RewriteRule ^about-us/blog/?$ /index.php?section=About%20Us&subsection=Blog [L]

any one see anything wrong with how i set it up, I did read some place that mod-rewrite has to be enabled so that may be the problem waiting on a call back from host. Is there any way for me to check to see if mod-rewrite is enabled (kind of like a phpinfo() command or anything)?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum