1

i face the following problem:

My folder structure in the server is: public_html/projects/

Tree view: folder structrure tree view

In the public_html folder there is an .htaccess file.

Inside the projects folder my partners will create numerus folders with a landing page inside (let's say just an index.php file)

The rewrite rules that i try to apply is a language and a currency url parameters.


So, for example this url: https://www.example.com/projects/whatever-project-name/index.php?lang=en&currency=eur

has to be translated to: https://www.example.com/projects/whatever-project-name/en/eur/

Also, the currency variable is optional. (The language variable is a mandatory variable)

So the urls may be something like this too: https://www.example.com/projects/whatever-project-name/en/


I'm searching and trying (and crying) a couple of days now in order to solve this problem. The only one solutions that is close to mine is this: RewriteRule for unknown directory

but i didn't manage to make it work.

What i have till now (but it doesn't work properly) is:

RewriteEngine On
RewriteRule ^(.*/)?/([a-zA-Z0-9]{2,3})/([a-zA-Z0-9-]+)/?$ projects/$1index.php?lang=$2&currency=$3
RewriteRule ^(.*/)?/([a-zA-Z0-9]{2,3})/?$ projects/$1index.php?lang=$2[L]
E_net4
  • 27,810
  • 13
  • 101
  • 139

1 Answers1

3

Based on your shown samples, could you please try following. Please make sure you clear your cache of browser before testing your URLs.

RewriteEngine ON
##With currency variable in URI.
RewriteCond %{REQUEST_URI} ^/projects/([\w-]+)/en/([\w-]+)/?$ [NC]
RewriteRule ^(.*)$ projects/%1/index.php?lang=en&currency=%2 [L]

##Without currency variable in URI.
RewriteCond %{REQUEST_URI} ^/projects/([\w-]+)/en/?$ [NC]
RewriteRule ^(.*)$ projects/%1/index.php?lang=en [L]
RavinderSingh13
  • 130,504
  • 14
  • 57
  • 93