Forum Moderators: phranque

Message Too Old, No Replies

mod rewrite paths, confused

         

riquez

3:30 pm on Feb 13, 2007 (gmt 0)

10+ Year Member



Hi!

I've used mod_rewrite before, but not in the way I am now attempting. I find the syntax difficult & I admit I don't fully understand.

I'm working on a new site, it's quite simple & database driven. My ideal solution is to have 1 page (index.php) which displays the required info from the db (home/about/contact/etc)

I would like to use mod_rewrite to convert the url:
>> example.com/index.php?lang=en&page=home
into:
>> example.com/en/home

So far I have it working, but my image & css links are not working & I am confused by the inconsistency of this.
EG: here is the .htaccess


RewriteEngine on
RewriteRule ^(.*)/(.*)$ index.php?lang=$1&page=$2

[ the 1st (.*) will be the language (en/jp) & the 2nd (.*) the page name (home, contact, about us etc) ]
This is currently working for the basic php/html page.

In this page I have several hard-coded links to CSS & images - however the results confuse me:


<link href="/website/basic.css" rel="stylesheet" type="text/css" /> [b]= THIS WORKS[/b]
<img src="/website/images/header_logo.jpg" /> [b]= THIS DOES NOT WORK[/b] (missing image)

Ideally, I would like the rewrite to expect ( /en/home/ ) & only rewrite those url's
(2 letter code) + (/) + (1-10 letter word) but that's beyond me at the moment.

Any advice on what could be the problem would be greatly appreciated!

Thanks,
Riquez

jdMorgan

5:57 pm on Feb 13, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This thread from our library should help with several issues: Changing Dynamic URLs to Static URLs [webmasterworld.com]

Jim