V
V
Viktor2020-01-13 08:51:27
htaccess
Viktor, 2020-01-13 08:51:27

How to redirect a request to a child folder?

There is a structure like this:

site:
  folder1:
    index.php
    some_file.txt
  script.php
  .htaccess

Task: when a request is received to script.php, execute it, in other cases, redirect the request to the folder1 folder.
Tritely, a request to site/script.php will execute script.php, but site/index.php or site/some_file.txt will execute the corresponding files.
I tried, but it gives 500:
RewriteEngine on
RewriteCond %{REQUEST_URI} !script.php
RewriteRule ^(.*)$ folder1

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dodo512, 2020-01-13
@P1nkmen

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/folder1/
RewriteCond %{REQUEST_URI} !^/script\.php
RewriteRule ^(.*)$ /folder1/$1 [L]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question