Reputation: 908
I want to rewrite only the ROOT of my subfolder, which means:
If I go to: localhost/a/b/
then this should be redirected to localhost/a/
but localhost/a/b/c/
should stay the same. So that only a request to the subfolder b directly will be rewritten and nothing under the directory b, like c.
I already tried a few things like this:
RewriteCond %{HTTP_HOST} !^b$
RewriteRule ^$ /a [L,R=301]
or
RewriteRule ^/$ /a
or
RewriteRule ^/a/b/$ /a
I can't seem to find the correct solution.
Upvotes: 1
Views: 23
Reputation: 784918
You can use this rule in site root .htaccess:
RewriteEngine On
RewriteRule ^a/b/?$ /a [L,NC]
This is assuming there is no other .htaccess in your system and this is first rule.
If you want to do this in a/.htaccess
then:
RewriteRule ^b/?$ /a [L,NC]
If you want to do this in a/b/.htaccess
then:
RewriteRule ^/?$ /a [L]
Upvotes: 1