Msg#: 4445265 posted 7:25 am on Apr 25, 2012 (gmt 0)
I have the link below which I created to test the functionality of the script I wrote. But because the rest of my site is setup with friendly or extensionless URLs, I want to do the same with this one:
Msg#: 4445265 posted 8:52 am on Apr 25, 2012 (gmt 0)
Use example.com in this forum.
Never use (.*) in the middle of a pattern. It means capture everything to the end of the input.
The link should specify the URL format that you want your users to see and use. You can make it whatever you want. The pattern in the rule then has to match that format in order for the rewrite to happen.
I would use href="/mp4323" or href="/mp-4323" or similar for the link. The rule pattern then has to test for "mp-" and for "digits", capture the digits and rewrite to the named .php file passing ?page=$1 to it.
Msg#: 4445265 posted 9:45 am on Apr 25, 2012 (gmt 0)
The linked-to example code is a good start, but there are several major flaws.
The text after the page number is optional in the pattern. That's a duplicate content issue. The text isn't passed to the script to check it matches for this page number. That's another duplicate content issue.
i.e. /product-45433 and /product-45433-acme-rotating-widget both return the same content.
i.e. /product-45433-acme-rotating-widget and /product-45433-this-is-overpriced-junk both return the same content.
Don't make the text optional. Pass the $2 parameter to the script. Reject request if $2 isn't correct for the requested $1.
The tutorial also omits the required [L] flag and allows URLs with spaces, but that's entirely another matter.
Your current RewriteRule code fails because (.+)? is for capturing optional text but the ^mp-([0-9]+)- part says that a hyphen is required after the page number.
Your RewriteRule code is looking for requests like /p-2- or /p-2-something but you are requesting just /p-2 here.
If you just want page number and no text in the link, the -(.+)? part can be discarded from your RewriteRule code.
RewriteBase / is the default and can be omitted.
Add a leading / before the target .php filename in the RewriteRule. Get into the habit of doing this for all internal rewrites.