Forum Moderators: phranque

Message Too Old, No Replies

rewrite url also changes the links from that page

         

Gatsu

11:02 pm on Aug 26, 2010 (gmt 0)

10+ Year Member



.htaccess:
RewriteEngine On
RewriteRule ^open/([0-9]*)/(.*)/$ open.php?id=$1&rub=$2

The link:
<a href="open/'.urlencode($add['id']).'/'.urlencode($rub).'/">yada </a>

The problem:
The open.php changes also all the links from that page to other pages so my css file and all links are wrong.

The URL turns out as it should tho...

Thanks for reading.

g1smd

11:08 pm on Aug 26, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This topic has come up at least three times in the last 48 hours. Please check recent threads for full information.

The main parts of the problem:
1. URLs for pages should not end with a trailing slash. The trailing slash denotes a folder.
2. Do not use relative links to link to images and scripts. Begin the link URL with a slash, denoting the root, and include the full folder path to that file.

jdMorgan

12:26 pm on Aug 27, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Correct the link:

<a href="/full-server-path-to-open/'.urlencode($add['id']).'/'.urlencode($rub).'/">yada </a>

or

<a href="http://www.example.com/full-server-path-to-open/'.urlencode($add['id']).'/'.urlencode($rub).'/">yada </a>
It is the client (a browser in this case) that resolves relative links on pages, based on the "page URL" that it shows in its address bar. Since you have now changed all of the page URLs, the browser thinks that all of these included objects are in the same "virtual subdirectories" as your pages now appear to be in.

Jim