By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,795 Members | 1,660 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,795 IT Pros & Developers. It's quick & easy.

mod_rewrite Directory Problem

P: n/a
I'm trying to replace a PHP query string with virtual directories using
Apache's mod_rewrite. Here's my test .htaccess:

RewriteEngine on
RewriteRule ^qqq$ database.php?cat=0
RewriteRule ^qqq/xxx$ database.php?cat=0

The problem is that database.php contains several relative paths to
images. This means mydomain/qqq works fine and all the images are found
but when typing mydomain/qqq/xxx the file database.php seems to think it
is in the xxx directory and cannot find the images.

What, apart from not using relative paths in database.php, can be done
to make things work correctly so that database.php always thinks it is
in the root directory and finds the images?

Regards

R.
Jun 8 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Rik G. wrote:
I'm trying to replace a PHP query string with virtual directories
using Apache's mod_rewrite. Here's my test .htaccess:

RewriteEngine on
RewriteRule ^qqq$ database.php?cat=0
RewriteRule ^qqq/xxx$ database.php?cat=0

The problem is that database.php contains several relative paths to
images. This means mydomain/qqq works fine and all the images are
found but when typing mydomain/qqq/xxx the file database.php seems to
think it is in the xxx directory and cannot find the images.

What, apart from not using relative paths in database.php, can be done
to make things work correctly so that database.php always thinks it is
in the root directory and finds the images?

Regards

R.


Methnks that question might be better in alt.apache.configuration or even
over at http://www.mod-rewrite.com/forum/
Jun 8 '06 #2

P: n/a
Rik G. wrote:
What, apart from not using relative paths in database.php, can be done
to make things work correctly so that database.php always thinks it is
in the root directory and finds the images?


Define your image directory in .htaccess:

RewriteRule ^qqq/images/(.*)$ images/$1
regards,

Lorento
--
http://blog.deshot.com
http://www.groupvita.com

Jun 9 '06 #3

P: n/a
lorento wrote:
Rik G. wrote:
What, apart from not using relative paths in database.php, can be done
to make things work correctly so that database.php always thinks it is
in the root directory and finds the images?


Define your image directory in .htaccess:

RewriteRule ^qqq/images/(.*)$ images/$1
regards,

Lorento
--
http://blog.deshot.com
http://www.groupvita.com


Thank you, that does the trick.

R.
Jun 9 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.