modrewrite, ampersand in variable
-
28-06-2021 - |
Question
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-
?
Solution
Using a rule before your current rule:
RewriteRule ^(.*)&(.*)$ /$1-and-$2 [L,R=301]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow