Php Zend / MVC without mod_rewrite

I have seen this mentioned in many blogs on the net, but I believe this is discussed here. What can we do when we have the MVC infrastructure (I'm interested in ZEND) in PHP, but our host does not provide mod_rewrite? Are there "short cuts"? Can we somehow transfer control (so that a mapping can be displayed between pages)? Any ideas? Thanks: -)

+1
source share
5 answers

Zend structure should work without mod_rewrite . If you can live with your url: s is more like "/path/to/app/index.php/controller/action". If you have mod_rewrite, you can do away with the index.php bit, but it should work too.

It all depends on the route settings for receiving the index.php part.

+4
source

OK my verdict :-): I successfully used zend without mod_rewrite, and it, as you all said site / index.php / controller / action. I knew this before publishing this. I also found a method on the network that “pushes” 404 pages to index.php, so the resource (for example, CSS, image, etc.) does not get there, with one exception: POST values. So I decided that the next time the application should be done on a specific server, to politely ask mod_rewrite. If the administrator cannot provide it, talk to my boss or, if he is for me, switch to the provider. As a rule, sometimes it’s a shame that the PHP market is so fragmented (php4, php5, php6, mod_rewrite, mod_auth, mod_whatever), but this is another story ...

+1
source

mod_rewrite is practically necessary in today's hosting environment ... but, unfortunately, not everyone received the message.

Many large php programs (I think magenta, but most of them can handle it) have a return return mode pretty much when mod_rewrite is not available.

URLs look like www.site.com/index.php?load-this-page

They need to run magic to grab the variable name from the $ _GET variable and use it as a selector for which module / function should be executed.

In the corresponding note, I saw a lot of confused URLs on the new facebook site, where it uses #. Thus, the links look like www.new.facebook.com/home.php#/inbox/. Obviously, we should not see this, but this suggests that they are probably parsing the variable $ _SERVER ['REQUEST_URI'].

0
source

If you can find a non-mod_rewrite way to redirect all requests to index.php (or wherever your init script is), you can, as mentioned above, use "REQUEST_URI" to capture the part of the address after the domain and then parse it on your own and make a request to do what you want. This is exactly how Wordpress does this (provided, with mod_rewrite). While you can redirect requests to your index page while maintaining the same URI, you can do whatever you need to process the request.

0
source

Drupal rewrite rules translate

http://example.com/path/goes/here

in

http://example.com/index.php?q=path/goes/here

... and has the logic to decide what flavor URLs to generate. If you can live with ugly URLs, this will allow you to keep all the logic of one front controller in place, without relying on rewriting the URLs.

-2
source

Source: https://habr.com/ru/post/1339645/


All Articles