Forum Moderators: phranque

Message Too Old, No Replies

.htaccess rewrite breaks <script> and <link> links on a working page

         

daktau

12:35 pm on Jan 11, 2010 (gmt 0)

10+ Year Member



Hi,
I have a php page which works fine if entered directly eg...
url/page.php

but when accessed from a rewrite rule I receive lots of page errors to do with the linked css and javascript files, none of which seem to be linked.

How can the same code work differently when accessed from a rewrite rule?

<script type="text/JavaScript" src="javascript/jquery-1.3.2.min.js"/>
<LINK REL="StyleSheet" HREF="css/general.css" TITLE="Contemporary" TYPE="text/css"/>

Is there a way to avoid this?

thank you,
George

jdMorgan

3:47 pm on Jan 11, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Start your links with a slash, and make the paths relative to the DocumentRoot directory of your site -- specify the full path from your 'home page' directory on down.

It is the client (e.g. browser or search robot) that resolves relative links according to the URL that it 'sees' in its address bar. By changing the URLs seen by the browser, you have changed the 'base locations' used to calculate the location of these page-relative links.

Jim

daktau

4:21 pm on Jan 11, 2010 (gmt 0)

10+ Year Member



Thanks for that, it is useful to know.
I have it now working with /

cheers,
George