Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite URl

I finally did it...

         

willybfriendly

11:15 pm on Oct 23, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, after studying these boards I finally succeeded in re-writing a dynamic URL to a static one.

I'm jazzed.

But, I ran into a problem along the way that I thought I would share with other nubes.

I lost my style sheet. Pages looked like crap. Couldn't figure out what was going on...

Then it struck my - my new [mysite.com...] - was being seen as a new directory by the server. Changed my relative URL for the stylesheet to an absolute URL and the pages now display as they should.

WBF

jdMorgan

12:44 am on Oct 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You should be able to use a local path with no problem. To clarify:
my_fine.css ------------------------- relative 
/my_fine.css ------------------------ absolute (refers to server document_root)
http://www.example.com/my_fine.css -- canonical (and therefore also absolute)

Jim

willybfriendly

2:23 am on Oct 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Interesting,

<LINK rel="stylesheet" type="text/css" href="style.css">

did not work, but when I changed it to,

<LINK rel="stylesheet" type="text/css" href="http://www.mysite.com/style.css">

it immediately began working.

Now, as I was scratching my head looking at the non-working version, the thought hit me that it must be interpreting the page as being in a new folder, since that is how the URL appears, so the fix would be the full URI to the style sheet.

This is the .htaccess I am using:

Options +FollowSymLinks
RewriteEngine on
RewriteRule find-farm/(.*)/(.*)/$ /my-file.php?$1=$2

So, any insight into what's up?

WBF

(By the by, the rewrite is just too simple when it works. Wish Ihad done this loooong ago :))

jdMorgan

3:24 am on Oct 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What my previous post means in your case is that
 <LINK rel="stylesheet" type="text/css" hre[b]f="/s[/b]tyle.css"> 

should work.
The leading slash makes the link "relative" to your document_root, rather than relative to the directory of the page where this Link_Rel is located. So, it specifies an "absolute" location on your server.

The form you have specified -- using the canonical URL -- is equally valid but makes it difficult to use the code across multiple sites. This is a big concern for some, and of no consequence whatsoever for others.

Jim

willybfriendly

3:32 am on Oct 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks jdmorgan. Believe it or not,that makes sense to me.

WBF