Jump to content

Archived

This topic is now archived and is closed to further replies.

AdRock

rewrite rules conflicting [RESOLVED]

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?

Share this post


Link to post
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.

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

×

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.