Jump to content

Recommended Posts

Posted

Есть сайт с тремя точками входа: index.php, client.php и operator.php. Индексный файл по умолчанию (DirectoryIndex) — index.php.

Нужно преобразовывать пути в URI следующим образом:

site/                        -> index.php
site/id                      -> index.php?id=$id
site/path/                   -> index.php?cat=$path
site/path/id                 -> index.php?id=$id&cat=$path
site/path1/path2/path3/      -> index.php?cat=$path (/path1/path2/path3)
site/path1/path2/id          -> index.php?id=$id&cat=$path
site/user/                   -> client.php
site/user/id                 -> client.php?id=$id
site/user/path/              -> client.php?cat=$path
site/user/path/id            -> client.php?id=$id&cat=$path
site/user/path1/path2/path3/ -> client.php?cat=$path
site/user/path1/path2/id     -> client.php?id=$id&cat=$path
site/oper/                   -> operator.php
site/oper/id                 -> operator.php?id=$id
site/oper/path/              -> operator.php?cat=$path
site/oper/path/id            -> operator.php?id=$id&cat=$path
site/oper/path1/path2/path3/ -> operator.php?cat=$path
site/oper/path1/path2/id     -> operator.php?id=$id&cat=$path

То есть путь передается в переменной cat, содержимое после последнего слеша передается в переменной $id и если подкаталог первого уровня равен user или oper, то они из пути удаляются и меняется точка входа.

Если в строке адреса были другие переменные (был GET-запрос с параметрами), они должны сохраниться.

Возможет также такой вариант:

site/user -> user.site/ -> client.php

site/oper -> oper.site/ -> operator.php

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...
На сайте используются файлы cookie и сервисы аналитики для корректной работы форума и улучшения качества обслуживания. Продолжая использовать сайт, вы соглашаетесь с использованием файлов cookie и с Политикой конфиденциальности.