Assuming this is in the root .htaccess
file...
RewriteRule ^(da-dk)/(.*)(/|\.php)$ /$2$3 [L]
A request for /da-dk/
(which matches against the URL-path da-dk/
) does not match the regex ^(da-dk)/(.*)(/|\.php)$
so this rule is not processed/followed.
So, unless you have other rules that match this request then no rules are followed, hence the 404. (As for what rules are "encountered", well, all the other rules you have are encountered.)
Incidentally, the preceding condition (RewriteCond
directive) is entirely superfluous here and should be removed. It's not doing anything more that what the RewriteRule
pattern has already established.
Specifically, this rule (regex) would match URLs of the form:
/da-dk/.php
/da-dk/<foo>/
/da-dk/<foo>.php
/da-dk/<foo>/<bar>/<baz>/
/da-dk/<foo>/<bar>/<baz>.php
It does not match:
This rule simply removes the /da-dk
prefix on the requested URL (presumably in the hope that the rewritten URL matches a filesystem directory or file).
If /da-dk/
should be rewritten back to the root then the above rule can be modified to allow for this (in the process, it can also be simplified slightly). For example, try the following instead:
RewriteRule ^da-dk/(.+(/|\.php))?$ /$1 [L]
Here, the part of the URL-path after da-dk/
is made optional. (In this case, the $1
backreference is effectively empty.)
By changing the quantifier from *
to +
this also avoids matching the (nonsense) URL /da-dk/.php
.
No need to capture the da-dk
part (first path segment), since this is not being used in the substitution string (2nd argument).
The $1
backreference now contains the entire URL-path after the da-dk/
prefix. (No need for $2
and $3
as you had originally.)