473,396 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

mod_rewrite Directory Problem

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
3 1956
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Support | last post by:
Hello, I am running RedHat & Apache. RedHat does not allow creating more that 32000 subdirectories in one folder due to #defined constant limitation in the core code. I need to display 47000...
5
by: laredotornado | last post by:
Hi, I have verified that mod_rewrite is enabled on my Apache 2.2 instance. However, now I'm having a problem just serving pages using .htaccess files. Following Rik's advice, my .htaccess file...
0
by: narian | last post by:
Hi, I am trying to convert urls from this format: http://localhost/index.php?section=11 (where 11 is the id of the row in a table) to this friendly url: http://localhost/services.html...
1
by: jaimebienlesfruits | last post by:
Hi, I'm currently using mod_rewrite to rewrite URLs with server variables. RewriteEngine on RewriteRule ^(+)$ /layout4/$1/ RewriteRule ^(+)/?$ index.php?dir=&page=$1 RewriteRule...
2
by: jaanus | last post by:
Here we go... What I have been trying to do is to forward all http requests containing /cms/ to http://cms.mydomain.com/ example1: http://host1.mydomain.com/cms/init.php would be parsed from...
3
by: Kevin Audleman | last post by:
When you type in a url without a filename, e.g. www.google.com/, it automatically looks for index.php (or whatever your web server is configured to look for). I am having the problem where my CMS...
1
by: macaco | last post by:
I'd like to redirect URLs in a directory in this way: categories/anything/index.php?id=13 to categories/index.php?id=13 To achieve that, I've uploaded a .htaccess file to "categories"...
2
by: LC's No-Spam Newsreading account | last post by:
On Tue, 7 Oct 2008, Grant wrote: I carefully RTFM, but can't find an example like my case. What is the " fake directory cgi option" ? (in general I avoid using /cgi-bin or personal...
1
by: cptuser | last post by:
Hi, I'm struggling to find an answer to my problem. In order to make my dynamic URLs search engine friendly, I need to replace spaces (%20) that appear in the URL with a dash "-". For...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.