Forum Moderators: phranque
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]
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]