F
F
ffrage2021-04-19 21:47:31
htaccess
ffrage, 2021-04-19 21:47:31

How to make beautiful urls in .htaccess?

Good evening!

I tried many options from the forums, but for some reason nothing helps.

On the site page (main.php), rows from the database are generated:

<a href='article.php?post=" . $t['url'] . "'>" . $t['title'] . "</a>


Clicking on the line opens the page with the article. I want to use the .htaccess

file , which lies at the root of the site, to change the link: fittalble/article.php?post=proverka to: fittalble/proverka No matter how I tried to edit the second line, the site ignores any changes to the url, only breaks if something it's not like this:




RewriteEngine On
RewriteRule ^/(.*)$ article.php?post=$1 [NC,L]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
ffrage, 2021-04-20
@ffrage

Found the solution CNC Tuning Guide .
The bottom line is that you need to create pages with the required url, for example:

<a href="article1">статья 1</a>
<a href="article2">статья 2</a>

And only then convert to .htaccess :
RewriteEngine On
RewriteRule ^(.*)$ /article.php?url=$1 [L]

Those. we create a beautiful CNC link (site.ru/article1), and then in .htaccess , figuratively, we enter information into it (site.ru/article.php?url=article1).
Killed a few days to understand this logic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question