Thanks Owen. I figured that's what was happening but I was hoping there was some voodoo I could do to keep things relative but mask what is in the URL. I suppose I could separate it like, /~user/list/foo-ABC-XYZ That wouldn't be too bad. Well thanks for your help. Weldon - Original message - I think the point you are missing is that it i... On 4/22/08, Boyle Owen <Owen.Boyle@xxxxxxx> wrote: > > -----Original Message----- > > From: Weldon Sams [mailto:wjsams@xxxxxxxxx] > > Sent: Monday, April 21, 2008 10:27 PM > > To: users@xxxxxxxxxxxxxxxx > > Subject: Relative images and css lost after Rewrite > > > > Hi, I have a question related to losing my styling and images after > > performing a Rewrite if anyone has some spare time. > > > > Here below is my scenario. > > > > --- > > > > I have a script located at, > > > > http://www.example.com/~user/scripts/list.php > > > > This script accepts a query string of the format, > > > > sort=foo&gn=ABC&dn=XYZ > > > > where ABC and XYZ are of the regular expression form [A-Z]* > > > > I have placed a .htaccess file in /~user/ with the contents, > > > > ##################### > > RewriteBase / > > > > ### 1st rule: (New URL request form) > > ### /~user/list/foo/ABC/XYZ > > RewriteCond %{REQUEST_URI} list/(foo)/([A-Z]*)/([A-Z]*)$ > > RewriteRule ^.*$ > > /~user/scripts/list.php?sort=%1&gn=%2&dn=%3&stoprewrite=1 [L] > > > > ### 2nd rule: (Request for the old URL format) > > ### /~user/scripts/list.php?sort=foo&gn=ABC&dn=XYZ > > RewriteCond %{REQUEST_URI} list.php$ > > RewriteCond %{QUERY_STRING} sort=(foo)&gn=([A-Z]*)&dn=([A-Z]*) > > RewriteCond %{QUERY_STRING} !stoprewrite > > RewriteRule ^.*$ /~user/list/%1/%2/%3? [R,L] > > ##################### > > > > The problem is that I'm losing my CSS styles and images or any links > > that are in the HTML which are relative links. Instead of being > > relative to /~user/scripts, I supposed they're trying to be relative > > to /~user/list/foo/ABC/XYZ > > > > I'm not sure how to phrase the question, but does anyone have an idea > > on how to make my URLs be of the form /~user/list/foo/ABC/XYZ but have > > the script run from /~user/scripts and all links in the HTML that is > > output be relative to /~user/scripts where it was ran from. > > > > I'd like to go to > > > > http://www.example.com/~user/list/foo/ABC/XYZ > > > > instead of > > > > http://www.example.com/~user/scripts/list.php?sort=foo&gn=ABC&dn=XYZ > > > > even though the script will always be located at > > /~user/scripts/list.php . > > > > Thanks for any help, and I'll be glad to rephrase if I'm not so clear, > > I think the point you are missing is that it is the *browser* that > requests the CSS and images. It does this when it gets the HTML output > back from the cgi script. So if it sees, in the HTML page, an <img> tag > with src="wibble.png", it will take that URL to be relative to the > URL-path of the current page (www.example.com/~user/list/foo/ABC/) so it > will request www.example.com/~user/list/foo/ABC/wibble.png. > > Basically, the browser doesn't know that the apparently static URL was > internally rewritten to a CGI script. > > One solution is to use absolute paths in the tags, eg, <img > src="/~user/list/foo/ABC/wibble.png">. Alternatively, move the image and > CSS content from the scripts dir to ~user/list/foo/ABC (if it exists). > Or, move the stuff to independent directories under the docroot and > refer to it using absolute paths, eg src="/images/wibble.png", > src="/styles/myStyle.css" etc. > > Rgds, > Owen Boyle > Disclaimer: Any disclaimer attached to this message may be ignored. > > > > > > > Weldon > > wjsams@xxxxxxxxx > > > > --------------------------------------------------------------------- > > The official User-To-User support forum of the Apache HTTP > > Server Project. > > See <URL:http://httpd.apache.org/userslist.html> for more info. > > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx > > " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx > > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx > > > > > This message is for the named person's use only. It may contain > confidential, proprietary or legally privileged information. If you receive > this message in error, please notify the sender urgently and then > immediately delete the message and any copies of it from your system. Please > also immediately destroy any hardcopies of the message. The sender's company > reserves the right to monitor all e-mail communications through their > networks. > > --------------------------------------------------------------------- > The official User-To-User support forum of the Apache HTTP Server Project. > See <URL:http://httpd.apache.org/userslist.html> for more info. > To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx > " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx > For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx > > -- Sent from Gmail for mobile | mobile.google.com | --- --- -- --- --- --- | Weldon Sams | wjsams@xxxxxxxxx | --- --- -- --- --- --- --------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx