Jump to content

[SOLVED] Mod Rewrite


jaymc

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.