S
S
Sergey2015-06-24 11:44:57
PHP
Sergey, 2015-06-24 11:44:57

How to properly configure htaccess for mvc (php)?

There is MVC
How data is passed for the controller
RewriteRule ^([^/]*)/([^/]*)$ index.php?route=$1/$2 [L]
$1 - controller
$2 - view
For example user/cabinet
What do I need
So that when typing in the url mysite.com/ hello
, the controller and view I need are connected
You can do this
RewriteRule ^(hello)$ index.php?route=controller/view [L]
But for me this is not quite suitable
Since instead of hello - maybe be any text. (not known in advance)
I think the problem itself lies somewhere here
RewriteRule ^(.*)$ index.php [F,L]
I searched, read, watched, tried - but I don't have enough knowledge to understand.
At the controller, I will check, if there is no information in the database, then I will output to the main page controller.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
ShamblerR, 2015-06-24
@seregali

Once again I say, I don’t know how many times I repeated the GET parameter is not part of the url, to redirect with GET you need to use a different construction.
all converge to one.

RewriteCond %{REQUEST_URI} /test/
RewriteCond %{QUERY_STRING} ^id=229
RewriteRule ^.*$ /supermodel/? [R=301,L]

g.zeos.in/?q=301%20%D1%80%D0%B5%D0%B4%D0%B8%D1%80%...

T
trevoga_su, 2015-06-25
@trevoga_su

www.phpinfo.su/articles/practice/chpu_na_php.html

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question