L
L
lexstile2018-09-27 15:58:47
htaccess
lexstile, 2018-09-27 15:58:47

How to properly strip part of url (without 301 response code)?

there is a structure:
site.ru/dir1/folder1/index.php
site.ru/dir1/folder2/index.php
site.ru/dir1/folder3/index.php
.............. ...............
how to trim the first part of the url?
To url like:

site.ru/dir1/folder1/ или site.ru/dir1/folder1/index.php

became like this:
site.ru/folder1/ или site.ru/folder1/index.php

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2018-09-28
@lexstile

RewriteEngine On

RewriteCond %{ENV:REDIRECT_STATUS}   ^$
RewriteCond %{DOCUMENT_ROOT}/dir1/$1 -d
RewriteRule ^([^/]+)/.*$ /dir1/$0 [L]

Add to the beginning of .htaccess in the root of the site.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question