V
V
Viktor Goryachev2017-03-14 20:36:17
Apache HTTP Server
Viktor Goryachev, 2017-03-14 20:36:17

How to shorten two URLs at once with .HTACCCESS?

Hello!
Tell me, please, what to do in this situation:
Some pages of the site are located at domain.com /posts /name.php
Other pages of the site are located at domain.com /pages /name.php The task is to remove posts/
from the addresses of these pages and pages/ respectively. To solve the problem, I tried to apply the rules in .htaccess: RewriteRule ^([A-z0-9-]+)$ /posts/$1 RewriteRule ^([A-z0-9-]+)$ /pages/$1 As a result, this is:
3IscBRw.jpg

Answer the question

In order to leave comments, you need to log in

3 answer(s)
V
Viktor Goryachev, 2017-03-16
@russeobum

Thank you all for your participation.
1. We enter all the information about the page into the MYSQL database
2. We generate the page from the database "on the fly":
3. We set the generated page to the CNC (Human Understandable URL)
: to his daddy in the database, and PAGES in his.
Everything is clean. If there is a better way to do it, please correct me.

S
Shamsudin Serderov, 2017-03-14
@Steein

Stack - hurry to the rescue

V
Viktor Taran, 2017-03-15
@shambler81

in conda create conditions or, or
actually and that's it

RewriteCond %{REQUEST_URI}  ^([A-z0-9-]+)$/(posts|pages)/([A-z0-9-]+)/$1  [NC]
RewriteRule   .*  http://site.ru/%1%3

Where %1 is the bracket number in the conda, the analogue of $1 is straight from the rule.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question