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]
this needs placed .htaccess file /mysite/ folder.
if accessing
localhost/mysite/sv
without trailing slash, rule redirectlocalhost/mysite/sv/sv
expects language part (sv
oren
) 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
Post a Comment