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