petenaylor Posted October 31, 2012 Share Posted October 31, 2012 Hi all I am trying to re-write the following URLs: The first I have managed OK: http://www.peten.co.uk/clientarea/ford/?page=new-car To: http://www.peten.co.uk/clientarea/ford/new-car By doing this: RewriteRule ^([A-Za-z\-]+)$ ?page=$1 [QSA] However, my next URL is: http://www.peten.co.uk/clientarea/ford/?page=new-car&vehicle=ford-ka I want this to become: http://www.peten.co.uk/clientarea/ford/new-car/vehicle/ford-ka I can't seem to get this to be re-written? I have tried: RewriteRule (.*)/(.*)/ index.php?page=$1&vehicle=$2 But his ruins all my images and some don't load? Can you help me re-write the URL? Many thanks Pete Quote Link to comment https://forums.phpfreaks.com/topic/270130-mod-rewrite-on-two-query-strings/ Share on other sites More sharing options...
kicken Posted October 31, 2012 Share Posted October 31, 2012 It sounds like your issue is not with the re-write stuff, but with your HTML. You need to change how you reference your images so that they will work with the new URL style. For example if you're old url was http://www.peten.co.uk/clientarea/ford/?page=new-car and you're image take is like so: <img src="../../images/blah.jpg"> Then it will be searching for the image at http://www.peten.co.uk/images/blah.jpg. Once you implement you're rewrite rules and the page's URL becomes http://www.peten.co.uk/clientarea/ford/new-car/vehicle/ford-ka, that same image tag is going to be looking for the image at http://www.peten.co.uk/clientarea/ford/images/blah.jpg What you need to do is update the image URL's so they are correct using the new format. The easiest way to manage that would be to use an absolute url or a relative-to-root path, eg: <img src="http://www.peten.co.uk/images/blah.jpg"> or <img src="/images/blah.jpg"> Quote Link to comment https://forums.phpfreaks.com/topic/270130-mod-rewrite-on-two-query-strings/#findComment-1389122 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.