I
I
Ivan Ivanovich2020-04-02 09:35:30
URL Handling
Ivan Ivanovich, 2020-04-02 09:35:30

How to make a link prettier?

I usually do this:
index.php: news.php: Get record from database by url, url itself $_GET['a'] The link looks like this: And I would like to know how to convert this to a type Without OOP. Please tell me if there are articles or something else.
<a href="news?a=test"></a>


https://site.com/news?a=test

https://site.com/news/test

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
dodo512, 2020-04-02
@IwanQ

RewriteRule ^news/(\w+)$ /news.php?a=$1 [L]

D
Dmitry Baskakov, 2020-04-02
@dmitrybascacov

You can do it through .htaccess using this help.
As a result, you should get a similar rule:
RewriteRule ^news/(\w+?)$ /news/a?=$1 [L]
in this case, just use the same file and the same code, but specify /news/test in the layout

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question