Pretty URL with 3 parameters

65 views Asked by At

I'm working on a .htaccess file with 3 parameters but it should also work for 1 parameter or 2 parameter. I have a sample for 2 parameters one but I can't figure out how to make it with 3 parameters.

Here is my code:

RewriteEngine On

RewriteCond %{THE_REQUEST} \ /+devplus0/index\.php\?key=([^&]+)&lang=([^&\ ]+)
RewriteRUle ^ /%1/%2? [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/?$ index.php?key=$2&lang=$1 [L,QSA]

RewriteCond %{THE_REQUEST} \ /+devplus0/index\.php\?key=([^&\ ]+)
RewriteRUle ^ /%1/%2? [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/?$ index.php?key=$1 [L,QSA]

Thanks in advance

1

There are 1 answers

0
Tümer Koloğlu On

I have found the answer by mimicking the code above

Here is the new version:

RewriteEngine On

RewriteCond %{THE_REQUEST} \ /+devplus0/index\.php\?key=([^&]+)&lang=([^&\ ]+)
RewriteRUle ^ /%1/%2? [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/?$ index.php?key=$2&lang=$1 [L,QSA]

RewriteCond %{THE_REQUEST} \ /+devplus0/index\.php\?key=([^&\ ]+)
RewriteRUle ^ /%1/%2? [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/?$ index.php?key=$1 [L,QSA]

RewriteCond %{THE_REQUEST} \ /+devplus0/index\.php\?key=([^&]+)&lang=([^&\ ]+)&extra=([^&]+)
RewriteRUle ^ /%1/%2/%3? [L,R]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ index.php?key=$2&lang=$1&extra=$3 [L,QSA]