URL rewrite issue

I’m having trouble with a rewrite issue i thought i had working.


RewriteRule (.*)/(.*)-(.*)\\.html$ details.php?name=$2&storeID=$3
RewriteRule (.*)/(.*)-(.*)-(.*)\\.html$ details.php?name=$2&storeID=$3&cmspage=$4

RewriteRule (.)/(.)-(.*)\.html$ details.php?name=$2&storeID=$3 --? works with: www.domain.com/details/name_of_page_here-72.html

this doesn’t work it defaults to the above
RewriteRule (.)/(.)-(.)-(.)\.html$ details.php?name=$2&storeID=$3&cmspage=$4 –> www.domain.com/details/name_of_page_here-72-NewPage.html

Output should give me
Array
(
[name] => name_of_page_here
[storeID] => 78409
[cmspage] => NewPage

)

Remember that .* captures everything, including hyphens. That’s why your first rule matches your second scenario, because all it needs is at least one hyphen somewhere in the filename. I would try this:

RewriteRule (.)/COLOR=“#FF0000”[/COLOR]-COLOR=“#FF0000”[/COLOR]\.html$ details.php?name=$2&storeID=$3
RewriteRule (.
)/COLOR=“#FF0000”[/COLOR]-COLOR=“#FF0000”[/COLOR]-COLOR=“#FF0000”[/COLOR]\.html$ details.php?name=$2&storeID=$3&cmspage=$4

[^/\-] means match any character that is not a slash (to ensure you stay within the current path segment) or a hyphen (to ensure to capture only the segment of the filename between hyphens.

cool… i understand… thanks :slight_smile: