Jump to content


Photo

rewrite rules conflicting [RESOLVED]


  • Please log in to reply
3 replies to this topic

#1 AdRock

AdRock
  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 31 August 2006 - 09:34 PM

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?
If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 31 August 2006 - 10:22 PM

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.

#3 AdRock

AdRock
  • Members
  • PipPipPip
  • Advanced Member
  • 911 posts

Posted 01 September 2006 - 12:24 AM

I think i understand why it doesn't work.

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

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

What I would like is a url like this

mysite.com/gallery/image/1
If your topic has been solved, please mark the topic as SOLVED.

This helps others from identifying which topics need help still

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 01 September 2006 - 12:47 AM

yes that should work




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users