Jump to content

rewrite rules conflicting [RESOLVED]


AdRock

Recommended Posts

It seems to me that 2 of my rewrite rules are conflicting

RewriteRule ^([A-Za-z0-9]+)/([0-9]+)/?$ index.php?page=$1&id=$2
RewriteRule ^([A-Za-z0-9]+)/([0-9]+)/?$ index.php?page=$1&pagenum=$2

The first rule will work but the second rule won't.  If i reverse the rules the bottom one will work and the top one doesn't.

How do i sort it out so both rules work?
Link to comment
Share on other sites

Its becuase your expressions are exactly the same. You need to change the rewrite slightly so the expressions are unique. Such as for your secound rewrite rule have this as the url format:
mysite.com/pagename/page{pageNumberHere}

Where {pageNumberHere} is it'll be a number, eg:
mysite.com/pagename/page1

So use this as the rewrite rule for your secound expression:
RewriteRule ^([A-Za-z0-9]+)/page([0-9]+)/?$ index.php?page=$1&pagenum=$2

Now both expressions are unique Apache is able work out with expression to use, whereas before they where the same and apache couldn't see the difference between the two expressions.
Link to comment
Share on other sites

I think i understand why it doesn't work.

Is it to do with this bit [b]RewriteRule ^([A-Za-z0-9]+)/([0-9]+)/?$[/b] becuase they are both the same?

Could I rewrite this
[code]RewriteRule ^([A-Za-z0-9]+)/([0-9]+)/?$ index.php?page=$1&id=$2[/code]
to this
[code]RewriteRule ^([A-Za-z0-9]+)/image/([0-9]+)/?$ index.php?page=$1&id=$2[/code]

What I would like is a url like this

[b]mysite.com/gallery/image/1[/b]
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.