Answer the question
In order to leave comments, you need to log in
CNC implementation by storing the "url"-"query" link in the database. What are your opinions?
Good time of the day!
Interested in the opinion of specialists in the implementation of CNC in this way:
All requests to the site are redirected to index.php according to the following rule:
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [L]
SELECT `query` FROM `url_to_query` WHERE `url` = 'notebook-lenovob550-da02ua' LIMIT 1
parse_str($query,$_GET);
Answer the question
In order to leave comments, you need to log in
Look at the architecture of frameworks, etc. because it's all there already.
Than to pull the database every time, I would make, for example, such a folder / file structure as in yii, depending on the URL, this or that class / method is called.
/catalog/view/1
create a folder and a file in it: controllers/CatalogController.php and add the view method there.
Then just parse the url and depending on whether there is a class/method or not, show or output an error.
you can write a simple router in a few minutes, explode with a slash, the first argument is the name of the class, the second is the name of the method, and everything else is passed to the method and voila
your method, which you described above, I would use to write, for example, blog posts and so on .
It all depends on the specific case.
If this is a slug, it makes sense to store it in the database, but be sure to cache it, as an option - directly give it to nginx from memcached. But this is provided that you have at least an n-level url. Those. if in your example
`site.com/ notebook -lenovob550-da02ua` the highlighted is the NotebookController - then ok. The fact is that CNC parsing is part of the work of any request, and if it is slow for you, the polar fox has already crept up and is waiting))
Has the right to life in Redis / Memcached, provided that Notebook is a controller, and the rest is a slug.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question