skip to Main Content

I got a htaccess in my Root directory.

My files path http://example.com/folder1/folder2/index.php?country=eu&lang=en

I made this in htaccess.

RewriteCond %{HTTP_HOST} ^(www.)?anothersite.com$   
RewriteRule ^([^/]*)/([^/]*)$ /folder1/folder2/index.php?country=$1&lang=$2 [L]
RewriteRule ^([^/]*)$ /folder1/folder2/index.php [L]

And looks like this

http://example.com/index.php?country=eu&lang=en

But i want like this -> http://example.com/eu-en

Is there a way to do this in htaccess?

EDIT:
I have to use rewrite cond, because im redirecting to folders depends of host.

EDIT 2: SOLUTION

RewriteCond %{HTTP_HOST} ^(www.)?anothersite.com$   
RewriteRule ^([a-z]{2,2})-([a-zA-Z0-9_-]+)$ /folder1/folder2/index.php?country=$1&lang=$2 [QSA]

Thanks to answers, it is working now. But after that i got the css and js errors on website. Then i changed css and js paths /folder1/folder2/css.

2

Answers


  1. You need to append with the [QSA] (query string append) tag. Try

    RewriteEngine on
    
    RewriteRule ^([a-z]{2,2})/([a-zA-Z0-9_-]+)$ index.php?lang=$1&page=$2 [QSA]
    

    See http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html

    Login or Signup to reply.
  2. Try with below,

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^([^/]+)-([^/]+)$ index.php?country=$1&lang=$2 [QSA]
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search