Home Backend Development PHP Tutorial Configuring .htaccess single point of entry_PHP tutorial

Configuring .htaccess single point of entry_PHP tutorial

Jul 13, 2016 pm 05:51 PM
li mod rewrite different Entrance enable according to operating system module Adjustment Configuration first

First enable the mod_rewrite module (adjust according to different operating systems, currently Linux)
1. Apache enables Mod_rewrite module

Edit: /etc/apache2/httpd.conf
Uncomment: LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

2. Select Directory and change AllowOverride None to AllowOverride All.

3. Restart Apache

Create a file .htaccess in the project root directory and redirect the request to the public directory (adjust as needed)
1 <IfModule mod_rewrite.c>
2 RewriteEngine on
3 RewriteRule ^$ public/ [L]
4 RewriteRule (.*) public/$1 [L]
5 </IfModule>

Finally, forward the request to the public/index.php file, (distribute all requests here)

1 <IfModule mod_rewrite.c>
2 RewriteEngineOn
3
4 RewriteCond %{REQUEST_FILENAME} !-f
5 RewriteCond %{REQUEST_FILENAME} !-d
6
7 RewriteRule ^(.*)$ index.php?url=$1 [PT,L]
8
9 </IfModule>

app->public->index.php
This can achieve a single entrance to a website and is also the starting point of the MVC model. The next step can be to try to distribute our url as three parts controller/action/querystring.....


Excerpted from warcraft

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/478226.htmlTechArticleFirst enable the mod_rewrite module (adjust according to different operating systems, currently Linux) 1. Apache enables Mod_rewrite module editing: / etc/apache2/httpd.conf Uncomment: LoadModule rewrit...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

deepseek web version entrance deepseek official website entrance deepseek web version entrance deepseek official website entrance Feb 19, 2025 pm 04:54 PM

deepseek web version entrance deepseek official website entrance

How to install deepseek How to install deepseek Feb 19, 2025 pm 05:48 PM

How to install deepseek

Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node? Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node? Mar 05, 2025 pm 05:57 PM

Pi Node Teaching: What is a Pi Node? How to install and set up Pi Node?

gate Yishou app download official website gate.io app official download gate Yishou app download official website gate.io app official download Feb 21, 2025 pm 02:54 PM

gate Yishou app download official website gate.io app official download

Why can't the Bybit exchange link be directly downloaded and installed? Why can't the Bybit exchange link be directly downloaded and installed? Feb 21, 2025 pm 10:57 PM

Why can't the Bybit exchange link be directly downloaded and installed?

Coinsuper exchange software channel official website entrance Coinsuper exchange software channel official website entrance Feb 21, 2025 pm 10:39 PM

Coinsuper exchange software channel official website entrance

deepseek local deployment r1 model tutorial deepseek local deployment r1 model tutorial Feb 19, 2025 pm 03:51 PM

deepseek local deployment r1 model tutorial

BITGet official website installation (2025 beginner's guide) BITGet official website installation (2025 beginner's guide) Feb 21, 2025 pm 08:42 PM

BITGet official website installation (2025 beginner's guide)

See all articles