Forum Moderators: phranque

Message Too Old, No Replies

Mod Rewite partly working

         

elgumbo

3:45 pm on Jun 29, 2005 (gmt 0)

10+ Year Member



Hi

I am trying to get my head around the mod rewrite rule and have got somthing working (in a fashion)

I need to have www.mysite.com/hospitality/index.html redirect to www.mysite.com/hospitality/index.php

and www.mysite.com/hospitality/test/index.html redirect to www.mysite.com/hospitality/event_type.php?ID

and www.mysite.com/hospitality/test/testpage_xx.html redirect to www.mysite.co.uk/hospitality/detail.php/ID/ID2

I have managed to get it working by using the code below but I get a 404 error if somebody visits www.mysite.com/hospitality/test/

If I add a line to cover this problem it stops the first rule from working (www.mysite.com/hospitality/ redirecting to www.mysite.com/hospitality/index.php)

Any advice?

RewriteEngine on
RewriteRule ^hospitality/index.html$ http://www.mysite.co.uk/hospitality/index.php [L]

RewriteRule ^hospitality/([^/]+)/([^/]+)_([0-9]+)\.html$ http://www.mysite.co.uk/hospitality/detail.php/$3/$2 [L]

RewriteRule ^hospitality/([^/]+)/index.html$ http://www.mysite.co.uk/hospitality/event_type.php/$1 [L]

ChadSEO

10:46 pm on Jun 29, 2005 (gmt 0)

10+ Year Member



So essentially, you want /hospitality/whatever/ and /hospitality/whatever/index.html to both redirect to the same page, hospitality/event_type.php/whatever, right?

If I got that right, then you should be able to do something along the lines of:

RewriteRule ^hospitality/([^/]+)/(index.html)?$ [mysite.co.uk...] [L]

elgumbo

8:56 am on Jun 30, 2005 (gmt 0)

10+ Year Member



Yep that's it. That code works.

Thanks for your help.