Jump to content

Exclude certain word from pattern match


mb81

Recommended Posts

For purposes of SEO and content management, I use a simple rewrite code that takes a page name after a URL and send it as an id to the controller, like so:

RewriteRule ^([a-z0-9]+)$ content.php?id=$1 [L]

 

My challenge is this replaced a page structure that used files with similar names and a php extension, so I was trying to write a new rule that would take a URL like this:

http://www.mysite.com/page1.php

and change it to this:

http://www.mysite.com/page1

So that it would match the pattern of the items above, so I wrote this line:

RewriteRule ^([a-z0-9]+).php$ content.php?id=$1 [L]

 

But, this tries to rewrite content.php, so I need to exclude the following names from that match: index,content,header,footer

 

I tried a couple of different things, but couldn't get it to work, any help?

Link to comment
https://forums.phpfreaks.com/topic/98228-exclude-certain-word-from-pattern-match/
Share on other sites

Archived

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

×
×
  • 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.