N
N
nSnayp2014-02-20 18:12:19
PHP
nSnayp, 2014-02-20 18:12:19

CNC rewrite nesting: how?

Good afternoon!
There are urls like:
site.ru/catalog/razdel/1.php
site.ru/catalog/folder/2.php
site.ru/folder/papka/3.php
How to convert to a link like:
site.ru/2.php
site.ru/1.php
The sections are different, how can I do it without a database? But at the same time, you need to know which directory the page belongs to.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
FacedSID, 2014-04-15
@FacedSID

.htaccess

RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule .* index.php

index.php
$requestedString = explode('?', getenv('REQUEST_URI'));
$requestedString = $requestedString[0];

Well, you can manipulate it however you want. Any nesting level. Use any masks and regular expressions to get the data you need.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question