jaymc Posted June 3, 2008 Share Posted June 3, 2008 I use a lot of Mod ReWrite to produce nice URL's, see the example below RewriteRule ^hub/(.+)/(.+)/(.+)?$ ?open=hub&page=$1&catID=$2 [L] However, I want users to be taken to ?open=hub&page=&catID= if anything after hub/ is not defined Here is the full url www.site.com/hub/view_topics/123/topic.html # This works with the above mod rewrite www.site.com/hub # This does not work, it just loads a 404 When going to www.site.com/hub I would rather it produce this ?open=hub&page=&catID= How can this be done? Quote Link to comment https://forums.phpfreaks.com/topic/108509-solved-mod-rewrite/ Share on other sites More sharing options...
wildteen88 Posted June 3, 2008 Share Posted June 3, 2008 Yes use a new rewrite rule for your condition: RewriteRule ^hub$ ?open=hub [L] Also I do not suggested the use of (.+) as it is greedy. If all you want to do is match numbers then use ([0-9]+) for letters use ([a-zA-z]+) etc. Quote Link to comment https://forums.phpfreaks.com/topic/108509-solved-mod-rewrite/#findComment-556709 Share on other sites More sharing options...
jaymc Posted June 3, 2008 Author Share Posted June 3, 2008 Yeh I thought I would have to do that Also, you say greedy? Will this have any negative in pact if I use (.+) for everything? Quote Link to comment https://forums.phpfreaks.com/topic/108509-solved-mod-rewrite/#findComment-556759 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.