0

I'm trying to redirect my site from http://www.masterflooringtampa.com to go automatically to http://www.masterflooringtampa.com/en/ . I have been able to change my htaccess to do everything I needed except that. Please keep in mind that I use RewriteRule ^en/?$ index.php?lang_id=1 [NC,QSA,L] to direct to the correct php handler. Any htaccess expert can point in right direction? Also, if you have a shortcut or way to set up a formula to clean up the script (i'm just doing brute force, every url/link on its own approach that works but is not very elegant) I would be greatly appreciated.

<IfModule mod_expires.c>

  # defaults to the english site

  RewriteRule ^en/?$ index.php?lang_id=1 [NC,QSA,L]
  RewriteRule ^es/?$ index.php?lang_id=2 [NC,QSA,L]

  RewriteRule ^en/products/?$ products.php?lang_id=1 [NC,QSA,L]
  RewriteRule ^es/products/?$ products.php?lang_id=2 [NC,QSA,L]
  RewriteRule ^en/services/?$ services.php?lang_id=1 [NC,QSA,L]
  RewriteRule ^es/services/?$ services.php?lang_id=2 [NC,QSA,L]
  RewriteRule ^en/about/?$ about.php?lang_id=1 [NC,QSA,L]
  RewriteRule ^es/about/?$ about.php?lang_id=2 [NC,QSA,L]
  RewriteRule ^en/contact/?$ contact.php?lang_id=1 [NC,QSA,L]
  RewriteRule ^es/contact/?$ contact.php?lang_id=2 [NC,QSA,L]

  RewriteRule ^en/floors/hardwood/?$ floors/hardwood.php?lang_id=1 [NC,QSA,L]
  RewriteRule ^es/floors/hardwood/?$ floors/hardwood.php?lang_id=2 [NC,QSA,L]

  RewriteRule ^en/floors/carpet/?$ floors/carpet.php?lang_id=1 [NC,QSA,L]
  RewriteRule ^es/floors/carpet/?$ floors/carpet.php?lang_id=2 [NC,QSA,L]

  RewriteRule ^en/floors/laminate/?$ floors/laminate.php?lang_id=1 [NC,QSA,L]
  RewriteRule ^es/floors/laminate/?$ floors/laminate.php?lang_id=2 [NC,QSA,L]

  RewriteRule ^en/floors/tile/?$ floors/tile.php?lang_id=1 [NC,QSA,L]
  RewriteRule ^es/floors/tile/?$ floors/tile.php?lang_id=2 [NC,QSA,L]

  RewriteRule ^en/floors/vinyl/?$ floors/vinyl.php?lang_id=1 [NC,QSA,L]
  RewriteRule ^es/floors/vinyl/?$ floors/vinyl.php?lang_id=2 [NC,QSA,L]

</IfModule>

1 Answer 1

1

If i understand what you're asking then it seems like your site is working as it should do

And to clean your code you can replace your code with this

<IfModule mod_expires.c>

# defaults to the english site

RewriteRule ^en/?$ index.php?lang_id=1 [NC,QSA,L]
RewriteRule ^es/?$ index.php?lang_id=2 [NC,QSA,L]

RewriteRule ^(en)/([a-zA-Z])/?$ $2.php?lang_id=1 [NC,QSA,L]
RewriteRule ^(es)/([a-zA-Z])/?$ $2.php?lang_id=2 [NC,QSA,L]

RewriteRule ^(en)/([a-zA-Z])/([a-zA-Z])/?$ $2/$3.php?lang_id=1[NC,QSA,L]
RewriteRule ^(es)/([a-zA-Z])/([a-zA-Z])/?$ $2/$3.php?lang_id=2[NC,QSA,L]


</IfModule>
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the reply. It is working as intended. However, my problem is that I don't want Google to index masterflooringtampa.com but masterflooringtampa.com/en instead. I have a xml sitemap with alternates; however, currently traffic goes directly to masterflooringtampa.com and I would like to have that automatically go to masterflooringtampa.com/en by making a htaccess change. Hope I explained a bit better now

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.