Question

i've got some lil problem with my htaccess. My Links: http://example.com/log/?lang=en where log - it's a different directory and lang (en or uk or ru) But I want some pretty url LIKE: http://example.com/en/log/

Before I user regex:

RewriteRule ^([a-z]{2})/?$ index.php?lang=$1 [L,NC,QSA] 

RewriteRule ^([a-z]{2}(-[A-Z]{2})?)/(.*) $3?lang=$1 [L,NC,QSA] 

But can't find some decision for pretty URL

What I want:

By my logic I have to cut lang=en and paste together my host with request_uri like: host/en/?request_uri But how to do it?

Was it helpful?

Solution

Have it this way:

RewriteEngine On
RewriteBase /

RewriteCond %{THE_REQUEST} \s/+(log)/\?lang=([^\s&]+) [NC]
RewriteRule ^ /%2/%1? [R=302,L]

RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l
RewriteRule ^ - [L]

RewriteRule ^([a-z]{2})/?$ index.php?lang=$1 [L,NC,QSA] 

RewriteRule ^([a-z]{2}(-[A-Z]{2})?)/(.*) $3?lang=$1 [L,NC,QSA] 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top