Apache的Rewrite的两种办法并设置自动化header头Authorization

原创
小哥 3年前 (2022-11-02) 阅读数 67 #PHP
文章标签 PHP

一、 配置文件中的设置

<VirtualHost *:80>
ServerAdmin webmaster@example.com
DocumentRoot "/www/wwwroot/ceshidaili/public"
ServerName 6bcadd09.ceshidaili.local
ServerAlias ceshidaili.local

errorDocument 404 /404.html

ErrorLog "/www/wwwlogs/ceshidaili.local-error_log"
CustomLog "/www/wwwlogs/ceshidaili.local-access_log" combined

DENY FILES

<Files ~ (.user.ini|.htaccess|.git|.svn|.project|LICENSE|README.md)$>
Order allow,deny
Deny from all

PHP

<FilesMatch .php$>
SetHandler "proxy:unix:/tmp/php-cgi-73.sock|fcgi://localhost"

PATH

<Directory "/www/wwwroot/ceshidaili/public">
SetOutputFilter DEFLATE
Options FollowSymLinks
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm

AllowOverride none
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.)$ index.php?s=/$1 [QSA,PT,L]
RewriteRule .
- [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last]

二、 .htaccess 文件中的配置

<VirtualHost *:80>
ServerAdmin webmaster@example.com
DocumentRoot "/www/wwwroot/ceshidaili/public"
ServerName 6bcadd09.ceshidaili.local
ServerAlias ceshidaili.local

errorDocument 404 /404.html

ErrorLog "/www/wwwlogs/ceshidaili.local-error_log"
CustomLog "/www/wwwlogs/ceshidaili.local-access_log" combined

DENY FILES

<Files ~ (.user.ini|.htaccess|.git|.svn|.project|LICENSE|README.md)$>
Order allow,deny
Deny from all

PHP

<FilesMatch .php$>
SetHandler "proxy:unix:/tmp/php-cgi-73.sock|fcgi://localhost"

PATH

<Directory "/www/wwwroot/ceshidaili/public">
SetOutputFilter DEFLATE
Options FollowSymLinks
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
AllowOverride all

.htaccess文件中的内容:

<IfModule mod_rewrite.c> RewriteEngine on RewriteBase / RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?s=/$1 [QSA,PT,L] RewriteRule .* - [env=HTTP_AUTHORIZATION:%{HTTP:Authorization},last] </IfModule>

版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除

热门