Reputation: 1219
I have an URL that is https://www.myurl.com/subdir/language/login.php
.
The "language" parameter is not an existing subfolder. The folder structure is:
root/subdir/.htaccess
As you can see the .htaccess file is located in https://www.myurl.com/subdir/.htaccess
I would like to do a .htaccess Rewrite Rule in order to change the called uri:
https://www.myurl.com/subdir/en/login
(without .php)
to:
https://www.myurl.com/subdir/login.php?lng=en
My current apporach is:
# MultiViews must be disabled for the rewrite to work
Options -MultiViews
# Turn on the rewriting engine
RewriteEngine On
RewriteBase /subdir/
RewriteRule (en|de)(/login)$ login.php?lng=$1 [L]
But when I call the URI https://www.myurl.com/subdir/en/login
I get an http error code 404
.
Upvotes: 2
Views: 166
Reputation: 785156
Yes thats it! One more question, what if the scenario is all the same, but I would like to get the
(en/de)
in front of/subdir/
? So the url would bemyurl.com/en/subdir/login
:
In this case rule must be placed in site root .htaccess instead of subdir/.htaccess
with this rule:
Options -MultiViews
RewriteEngine On
RewriteRule ^(en|de)/(subdir/login)/?$ $2.php?lng=$1 [L,QSA,NC]
Upvotes: 2