[PHP] The Simplest PHP Router
작성일 22-12-14 20:30
페이지 정보
작성자sbLAB 조회 3,805회 댓글 0건본문
The Simplest PHP Router [PHP 프레임워크 미 사용]
아래 처럼 1번) .htaccess 생성 방법으로 할수 있으나 성능 상 비권장 => 2번) 방법을 이용
□ 1번) 웹사이트 루트디렉토리에(index.php와 같은 위치) .htaccess 파일생성
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [NC,L]
[참고]
Apache mod_rewrite Introduction
https://httpd.apache.org/docs/2.4/rewrite/intro.html#regex
https://waspro.tistory.com/198
Apache 웹서버 설정(httpd.conf)확인
LoadModule rewrite_module modules/mod_rewrite.so <== mod_rewrite.so 모듈활성화
DocumentRoot "D:/xampp/htdocs"
<Directory "D:/xampp/htdocs/jp">
Options Indexes FollowSymLinks Includes ExecCGI
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# AllowOverride FileInfo AuthConfig Limit
#
AllowOverride All #All => .htaccess를 사용하겠다는 의미, None => 사용안함.
Require all granted
</Directory>
□ 2번) .htaccess 파일을 생성하지 않고, 아파치 웹서버 httpd.conf 파일에 설정하는 것을 권장한다.
Apache 웹서버 설정(httpd.conf)확인
LoadModule rewrite_module modules/mod_rewrite.so <== mod_rewrite.so 모듈활성화
아파치 웹서버 httpd.conf 에서 설정
.htaccess 를 사용하지 않을 것이므로 AllowOverride None 으로 설정한다.
<Directory "D:/xampp/htdocs/jp">
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [NC,L]
</IfModule>
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride None
Require all granted
</Directory>
□ 웹사이트 루트디렉토리에 index.php 파일생성
웹사이트 루트디렉토리 아래에 jmp 폴더생성 -> datapage 폴더생성 -> php스크립트들 저장
[웹API 접근 url]
댓글목록
등록된 댓글이 없습니다.