mod rewrite - .htaccess - add language sub directory by default "sv/" (redirect) -


trying orientate myself through .htaccess jungle, i've narrated down rewrite problems 1 - adding language suffix upon entering page / typing in address doesn't have such one.

for example: visitor types mysite.com/kontakt. should take them default language of site, i.e. mysite.com/sv/kontakt. or, typing in mysite.com should take him/her mysite.com/sv/.

i'm developing site locally using mamp, , site located in subdirectory, , here's tricky part... how sort out in .htaccess file?

current code used:

rewritebase /mysite/   rewritecond %{request_uri} !^(sv|en)   rewriterule ^(.*)$ sv/$1 [l,r=301] 

and takes me localhost/mysite/ localhost/sv/. not right.

try one:

options +followsymlinks -multiviews rewriteengine on rewritebase /mysite/  rewriterule ^(?!(?:sv|en)/)(.*)$ sv/$1 [r=301,l] 
  1. this needs placed .htaccess file /mysite/ folder.

  2. if accessing localhost/mysite/sv without trailing slash, rule redirect localhost/mysite/sv/sv expects language part (sv or en) followed slash /.

p.s. , setting virtualhost -- there less (if none @ all) of such "tricky parts" accessing website via http://localhost/mysite/sv/kontakt (i'm sure agree, http://mysite.dev/sv/kontakt sounds , looks better).


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -