Hi, I'm trying to do a redirect with Mod Rewrite in .htaccess:
RewriteRule ^folder/([0-9]+)-([a-zA-Z0-9\-]+)\?(.*) folder/page.php?id=$1&shortname=$2&$3 [L]
So
http://mydomain.com/folder/1-word?status=success should rewrite to
http://mydomain.com/folder/page.php?id= ... us=success
but this isn't working. If I switch the question mark to a comma (without escaping) then I can use a comma instead of the question mark, but that makes for an odd-looking URL, I'd rather use the standard question mark format. Are question marks not valid in this scenario?
Thanks for any help you can offer.
Mod Rewrite with Question Mark
Moderator: General Moderators
Re: Mod Rewrite with Question Mark
I'm not very good with regex but why do you have "\-" here:
If nobody in this forum can help you, I'd recommend having an admin move your post to the regex forum.
Code: Select all
RewriteRule ^folder/([0-9]+)-([a-zA-Z0-9 \- ]+)\?(.*) folder/page.php?id=$1&shortname=$2&$3 [L]Re: Mod Rewrite with Question Mark
I needed to include the hyphen so that argument can contain numbers, letters and hyphen. That part works. It's just the question mark part that has issues.
Re: Mod Rewrite with Question Mark
As far as I know that should work... Like I said, maybe try the regex forum.target wrote:I needed to include the hyphen so that argument can contain numbers, letters and hyphen. That part works. It's just the question mark part that has issues.
Re: Mod Rewrite with Question Mark
RewriteRule works against the requested filename, not the entire request URI.
QSA will automatically append the query string.
Code: Select all
RewriteRule ^folder/(\d+)-([a-zA-Z\d-]+)$ folder/page.php?id=$1&shortname=$2 [L,QSA]