Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

modrewrite, ampersand in variable

I have a site with venues like AT&T Park. The links for this page should be: /venue.php?venue=at-and-t+park

Using htaccess, I've cleaned them up to look like.

RewriteRule venue/([^/]+)/{0,1}$ venue.php?venue=$1 [QSA]

So: /venue/AT-and-T+Park/

Problem: Somewhere google is finding and indexing links that look like this, which return as 403 errors. It's an ampersand issue.

/venue/AT&T+Park/

Is there way for me to change my rewrite rule to look for this oddball & and convert it to -and-?

like image 679
user401183 Avatar asked Feb 12 '26 08:02

user401183


1 Answers

Using a rule before your current rule:

RewriteRule ^(.*)&(.*)$ /$1-and-$2 [L,R=301]
like image 67
Jon Lin Avatar answered Feb 17 '26 04:02

Jon Lin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!