CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 31st, 2003, 07:10 AM
meddle's Avatar
meddle meddle is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Barcelona
Posts: 133 meddle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
paths to .js, .css, images lost when rewrite

I managed to run the following rewrite:
PHP Code:
 RewriteEngine on
RewriteRule 
^(.*).*/(.*)/ /$1.php 

that basically returns sub.domain.com/version/page.php when asked for sub.domain.com/version/page/
You see it's a simplified case. The problem here is paths to .js, .css and images are lost and I dont see them unless I declare them absolute (sub.domain.com/fullpath...) which obviously sucks. Any fix? Thanx

Reply With Quote
  #2  
Old January 31st, 2003, 11:08 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,966 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 52 m 24 sec
Reputation Power: 189
fix: donīt use mod_rewrite for that. use "DirectoryIndex" instead.
__________________
--
Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more.

Reply With Quote
  #3  
Old January 31st, 2003, 11:15 AM
meddle's Avatar
meddle meddle is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Barcelona
Posts: 133 meddle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
Dont have access to httpd.conf, sorry, should've said that beforehand. Thanx for any input.

Reply With Quote
  #4  
Old January 31st, 2003, 11:21 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,966 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 52 m 24 sec
Reputation Power: 189
how are you doing the url rewriting then? in .htaccess?
try putting the DirectoryIndex directive there.

Reply With Quote
  #5  
Old January 31st, 2003, 11:27 AM
meddle's Avatar
meddle meddle is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Barcelona
Posts: 133 meddle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
yes, using .htaccess. thanx, i'll have a look around here, if i dont find similar threads i'll ask again. Or can u post a simple example of how to do that using DirectoryIndex directive in .htaccess?

Reply With Quote
  #6  
Old January 31st, 2003, 11:32 AM
M.Hirsch M.Hirsch is offline
Contributing User
Dev Shed God 1st Plane (5500 - 5999 posts)
 
Join Date: Oct 2000
Location: Back in the real world.
Posts: 5,966 M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level)M.Hirsch User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Month 2 Days 52 m 24 sec
Reputation Power: 189
DirectoryIndex page.php

Reply With Quote
  #7  
Old February 3rd, 2003, 04:45 AM
meddle's Avatar
meddle meddle is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Barcelona
Posts: 133 meddle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
Sorry, i dont think you've read my problem, DirectoryIndex directive does other things. Thanx anyway.

I'll explain the problem again:

I have a folder we'll call 'version'. Under that folder there are the main php pages that become the sections of the site. I want those pages become folder status using .htaccess, but when doing so, references to relative paths (images, css, js, etc) are lost.

Reply With Quote
  #8  
Old February 3rd, 2003, 09:55 AM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 81
Send a message via AIM to Hero Zzyzzx
Then use absolute paths for your .js and .css files. Problem fixed.

Reply With Quote
  #9  
Old February 3rd, 2003, 10:01 AM
meddle's Avatar
meddle meddle is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Barcelona
Posts: 133 meddle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
No, I dont want to, problem not fixed. Isnt there any fix for that? I cannt believe it. Thanx anyway.

Reply With Quote
  #10  
Old February 3rd, 2003, 10:31 AM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 81
Send a message via AIM to Hero Zzyzzx
What's wrong with absolute paths? You don't have to put in a domain name. . .but you probably knew that.

Reply With Quote
  #11  
Old February 3rd, 2003, 10:38 AM
meddle's Avatar
meddle meddle is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Barcelona
Posts: 133 meddle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
I wouldnt like to HAVE to change all the links in a site, you know. I'm all ears, if you want to enlighten me with an example i'll appreciate a lot.

Reply With Quote
  #12  
Old February 3rd, 2003, 11:32 AM
Hero Zzyzzx's Avatar
Hero Zzyzzx Hero Zzyzzx is offline
11
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Jul 2001
Location: Lynn, MA
Posts: 4,635 Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level)Hero Zzyzzx User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 4 Days 23 h 44 m 19 sec
Reputation Power: 81
Send a message via AIM to Hero Zzyzzx
Hindsight is 20-20 they say. You should've gone with absolute paths from the start.

What I do for my sites is define a "js-lib" and "css-lib" directory directly up from the root that I put all my shared files in, then whenever I have to reference one of them I just put them in as absolute links:

Code:
<LINK REL="stylesheet" TYPE="text/css" HREF="/css-global/global.css"> 
<LINK REL="stylesheet" TYPE="text/css" HREF="/css-lib/diversity.css"> 
<script language="JavaScript" src="/js-global/global.js" type="text/javascript"></script> 


then, no matter where they are referenced from, they work.

The problems you're having are the exact reason NOT to use relative paths.

You could write a mod_perl post processing handler to fix the links, but it'd probably be better just to mass-update your links. There are a number of perl one-liners to do this. . .

Reply With Quote
  #13  
Old February 4th, 2003, 04:54 AM
meddle's Avatar
meddle meddle is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Barcelona
Posts: 133 meddle User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 11
cannt use that short way of absolute paths cause my subdomain can be accessed to from subdomain.domain.com or domain.com/subdomain. Obviously I dont want to change all my image references neither.

I dont want to use perl cause I'm already using php and cannt mix both on the same page.

I made a very simple test page with simple css/js/jpg associated files (all less than 3kb): http://meddle.dzygn.com/tests/htaccess/test.html

The main question is:
How can I make the page accessible through a non-existing http://meddle.dzygn.com/tests/htaccess/test/ (see the folder status)? And I'd need the associated files not corrupted by the rewrite change, so still accessible.

Thanx a lot.

Last edited by meddle : February 4th, 2003 at 05:01 AM.

Reply With Quote
  #14  
Old February 10th, 2003, 04:28 AM
freebsd freebsd is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2001
Posts: 5 freebsd User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
>> The problem here is paths to .js, .css and images are lost

Then fix your useless RewriteRule (because of using wildcard all over which basically matches everything more than you want it to really match) by adding a RewriteCond and another RewriteRule. When you are stuck just start here and pay attention to the keyword: Passthru or PT within RewriteRule.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > paths to .js, .css, images lost when rewrite

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap