overwrite .htaccess from subdirectory to root

I have some difficulties with mod_rewrite rules. I want to rewrite any request to

www.example.com/dev/* 

to

 www.example.com/* 

For example, when the request URL is www.example.com/dev/index.php , the response should be www.example.com/dev/index.php , and not only the URL looks like from the root directory, but actually it uses index.php from the root directory.

I tried mod_alias that works

 RedirectMatch (^/dev/)(.*) http://www.example.com/$2 

But you cannot apply the ip address conditions with mod_alias, so I still need a solution with mod_rewrite.

Can anyone share some knowledge? Thanks.

+6
source share
1 answer

How about something like that?

 RewriteRule ^dev/(.*)$ $1 

This should be in the root folder or applied to the primary Apache configuration (not in .htaccess).

The usual .htaccess redirection rules apply - including RewriteEngine on , Options FollowSymLinks and AllowOverride FileInfo . Full details at http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html#rewriterule .

+8
source

Source: https://habr.com/ru/post/904396/


All Articles