T
T
toha_man2018-06-14 22:38:59
Apache HTTP Server
toha_man, 2018-06-14 22:38:59

How to make convenient access to pages in Apache without an extension?

Friends, I often see links like http://[domainName]/pages/about on many sites - without the extension at the end of .html
On my local web server, such a trick out of the box does not work. How is it configured?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg Dobrygin, 2018-06-14
@odobrygin

You need a RewriteRule directive. Check out what .htaccess files are and how they can help you.
https://ruseller.com/lessons.php?id=309
www.htaccess-guide.com
https://www.nic.ru/help/fajl-htaccess-nastrojka-pe...

M
Maxim Fedorov, 2018-06-15
@Maksclub

Many sites don't do it the way you think
There are no physical files with any extension on the site, there is one entry point and there is a router that parses the address string and determines -- which part of the system call,
For example , /category/womens
the Router parses and sends a CategoryControllerparameter to the controller method. url=womens
This action already works with the database and selects the desired category from it with such an url and at the same time all the data in addition, then it all spits out into the layout (as an example) and you get the page
Before that, some CMS did this, the entry point was one index.php, but which controller to call was handled by the web server, not the router
For example, regular expressions are written in htaccess, which, for example, /category/womensredirect the address of the form to the address. Only instead of womens, an expression corresponding to any line isindex.php?module=CategoryController&url=womens
written in htaccess

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question