Mod rewrite urls and images

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Mod rewrite urls and images

Post by phpdevuk »

I know that somewhere someone has probably covered this, but I'm trying to use mod rewrite to take a url in the form of http://www.mysite.org/country/gb and rewrite it to go to http://www.mysite.org/country.php?code=gb

My .htaccess currently look like this, and does do what I want

Code: Select all

RewriteEngine On 
rewriteRule ^country/(.*)$ country.php?code=$1
problem is I get all images and links going to the wrong place so the page looks broken. I've read somewhere that I simply need to add rules for images etc, but I am stumped so far with getting anything to work.

Anyone help?
User avatar
phpdevuk
Forum Contributor
Posts: 220
Joined: Mon Jul 04, 2005 5:31 am
Location: UK
Contact:

Post by phpdevuk »

found a basic fix using the html tag base in the header file

Code: Select all

<base href=&quote;http://www.mysite.org&quote;>
Post Reply