.htaccess - remove directory after main url using htaccess -
with following url http://www.example.com/de/here/ want remove "de" directory (or whatever may in front of "here" directory, if in front of it) user directed http://www.example.com/here/ instead, directory exist.
the url http://www.example.com/it/here/ or other combination of 2 letters.
the url http://www.example.com/here/ in case don't want removed @ all.
i have searched solution here cant seem make work correctly appreciated.
you can use kind of htaccess :
rewriteengine on rewritebase / rewriterule ^[a-za-z]{2}/(.*)$ $1 [l,r=301]
example of redirections caused code :
http://www.example.com/de/foo/ => http://www.example.com/foo/ http://www.example.com/de/ => http://www.example.com/ http://www.example.com/it/bar/ => http://www.example.com/bar/ http://www.example.com/fr/baz/ => http://www.example.com/baz/
please note won't able access language (de, it, fr...) anymore.
another point, careful kind of url (the redirection executed twice) :
http://www.example.com/de/go/ => http://www.example.com/go/ http://www.example.com/go/ => http://www.example.com/
edit
now i've got more details, here htaccess can remove language specified folders :
rewriteengine on rewritebase / rewriterule ^[a-za-z]{2}/here/(.*)$ here/$1 [l,r=301] rewriterule ^[a-za-z]{2}/anotherfolder/(.*)$ anotherfolder/$1 [l,r=301]
Comments
Post a Comment