Forum Moderators: phranque
http://www.example.com/sectionName/pageName/
...and parses out the 2 GET variables to load a page like this:
http://www.example.com/pages.php?page=pageName§ion=sectionName
Here's the htaccess script:
RewriteEngine On
RewriteRule ^([a-zA-Z0-9\-\_\ \%]+)/([a-zA-Z0-9\-\_\ \%]+)/?$ pages.php?page=$2§ion=$1 [L]
This works fine on one server, but not another. I believe the problem is that it won't parse out the two variables that are separated by a slash. Instead, it treats them as one long variable named "page" -- pageName§ion=sectionName.
Any help is greatly appreciated.
Thanks.
[edited by: jdMorgan at 1:28 pm (utc) on June 1, 2009]
[edit reason] example.com [/edit]
Taking several shots in the dark here, I'm going to guess that MultiViews may be interfering, that the 'hyphen escaping bug' in alternate character groups may be causing a problem, or that you need to use the [NE] flag on the rule, because your URLs evidently contain percent signs which should be escaped.
Note that the [NC] flag is used for efficiency, allowing us to speed up the pattern matching about 30% by eliminating "A-Z" from the two subpatterns.
Options +FollowSymLinks -MultiViews
RewriteEngine On
#
RewriteRule ^([a-z0-9_%\ \-]+)/([a-z0-9_%\ \-]+)/?$ pages.php?page=$2§ion=$1 [[b]NC,NE[/b],L]
Also, look for other rules in your other config and .htaccess files that may rewrite this URL-pattern before this rule gets control.
Finally, if you just want to parse slash-separated fields, then a pattern like "([^/]+)/([^/]+)/?$ would be more efficient.
Jim
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteRule ^([a-z0-9_%\ \-]+)/([a-z0-9_%\ \-]+)/?$ pages.php?page=$2§ion=$1 [NC,NE,L]
Thanks for the help!
If you had posted your question only a few days later, I might have spotted that problem. But unfortunately, we both had to learn the hard way... :(
Jim
[edited by: jdMorgan at 2:42 pm (utc) on June 8, 2009]