Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mod_rewrite goes in wrong directory

Status
Not open for further replies.

sysadmin42

Technical User
May 6, 2005
138
Here's the rule I created:
Code:
RewriteRule ^page/([a-zA-Z0-9]*)/ index.php?content=$1
That in and of itself actually works fine. Example: changes to index.php?content=samplepage.

The problem is that all of the links and images are wrong. The links are all relative to /docroot/page/samplepage/ They really should be relative to /docroot/. So how do I get the mod_rewrite to rewrite the GET vars, but leave the current directory alone?

"Together we can make 'computer illiterate' a dirty word."
 
sysadmin42,

Just off the top of my head, if you change the links on index.php to begin with a leading slash, the path that follows should be relative to the DocumentRoot.

Example:
<img src="/path/to/foo.bar"> should point to /docroot/path/to/foo.bar.

I don't think mod_rewrite is the culprit here.

Wishdiak
A+, Network+, Security+, MCSA: Security 2003
 
is there a way to rewrite it so the links aren't relative?

right now, it's <img src="images/foo.bar"> and I'd like to keep it that way because there are a lot of images.

"Together we can make 'computer illiterate' a dirty word."
 
something like ?

RewriteCond ${REQUEST_URI} images/
RewriteRule ^(.*)images/(.*)$ /$1/images/$2

jeb \0
 
oops,
I meant

something like ?

RewriteCond ${REQUEST_URI} images/
RewriteRule ^(.*)images/(.*)$ /images/$2

jeb \0
 
worked like a charm! thanks!

"Together we can make 'computer illiterate' a dirty word."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top