I
I
im_dimas2020-07-04 12:55:16
PHP
im_dimas, 2020-07-04 12:55:16

How to redirect request to index.php?

Good afternoon, what should I write in .htaccess so that all GET requests to a site like /asd/zxc/qwe/asd/dfg/xcv/.../ (unlimited number of subfolders, if you can call it that. There can be 2 of them and 3 and 5) were sent to and processed in index.php at the root of the site? In index.php, you will need to process the string exactly as it appears in the address bar

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
netrox, 2020-07-04
@im_dimas

<IfModule mod_rewrite.c>
  Options -Multiviews
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule  ^(.+)$ index.php?url=$1 [QSA,L]
</IfModule>

In index.php, extract the query string via . $_GET['url']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question