Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multilanguage and mod_rewrite

I have a multilanguage website. I want the URL's to be like: http://example.com/en/blog_post/2 where blog_post is the name of the file blog_post.php and 2 is value of the parameter id.

I have this .htaccess code now

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(bg|en)/(.*)$ /$2?lang=$1 [L]
RewriteRule ^(bg|en)/(.*)/([^/.]+)$ /$2?lang=$1&id=$3 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]

I tried with this line, but it doesn't work:
RewriteRule ^(bg|en)/(.*)/([^/\.]+)$ /$2?lang=$1&id=$3 [L]

Can you help me please :)

like image 327
PYovchevski Avatar asked Oct 30 '22 22:10

PYovchevski


1 Answers

I did it. It works with these lines. Thanks to everyone :)

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^(bg|en)/post/([^/\.]+)$ blog_post.php?lang=$1&id=$2 [L]
RewriteRule ^(bg|en)/(.*)$ $2?lang=$1 [L]

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule (.*) $1.php [L]
like image 80
PYovchevski Avatar answered Nov 09 '22 14:11

PYovchevski