⊗ppMVDFmHSe 22 of 35 menu

Htaccess Configuration for MVC Framework in PHP

Now let's make it so that all requests from the address bar are addressed to our file index.php. That is, no matter what the user types into the browser, it will be addressed to index.php, and the code of this file will figure out which exact page to show to the user.

Here is the content of the file .htaccess:

RewriteEngine On RewriteBase / RewriteRule .+ index.php

Let's now remember that addresses from the folder project/webroot should not be redirected to the index, as that is where we store styles, scripts, images, and similar things. Let's account for this in our .htaccess:

RewriteEngine On RewriteBase / RewriteCond %{REQUEST_URI} !^/project/webroot/ RewriteRule .+ index.php

Create the file .htaccess. Perform the described configuration. Check its operation: all addresses, except for addresses from the folder project/webroot, should be redirected to index.php.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline