On a section of my site, I am currently using .htaccess rewrites to put the ID as part of the URL instead of in the query, like so:
RewriteRule ^([a-z_]+)?/?tours/([0-9]+)/(.*) /tours/tour_text.php?lang=$1&id=$2&urlstr=$3 [L]
For example, if someone goes to
/en/tours/12/some-text-here it will rewrite it to
/tours/tour_text.php?lang=en&id=12&urlstr=some-text-here. However I don't want the users to be able to put just any text, so if they type in the wrong
some-text-here part it will 301 redirect them to the right page.
This works perfectly, but I can see a potential problem arising when localizing the website, so I just wanted to make sure it's not actually a problem.
How it is now, if someone goes to
/en/tours/12/some-text-here, the anchor to the Spanish version of that page will be
/es/tours/12/some-text-here (i.e. only changing the "en" to "es"), and then the script will then 301 them to the correct Spanish text (something like
/es/tours/12/algun-texto-aqui). And the reverse will also be the same. The anchor on the Spanish version to the English version would be
/en/tours/12/algun-texto-aqui and then they will be forwarded with 301 back to
/en/tours/12/some-text-here. Basically, the anchor changes the language and the 301 changes the string at the end.
So I have two questions:
- Does purposely and permanently having invalid URLs on your site that get 301'ed to the correct ones have any effect on SEO? I could make it just show the correct URL to begin with, but this is a significant amount of work due to how I am handling the translations, so I would prefer just to 301 them.
- Will the invalid URLs that are contained in the links be added to the search engine indexes even if they get 301'ed to another page?