编写Apache配置文件,客户端IP119.128.128.28访问/www/wwwroot/80zx.com目录。其他IP访问/www/wwwroot/80zx.cn目录。这里还考虑到其他ip访问条件,具体代码
RewriteEngine On
#第一个IP条件
RewriteCond %{REMOTE_ADDR} ^119\.128\.128\.28$
RewriteRule ^/(.*)$ /www/wwwroot/80zx.com/$1 [L]
#第二个IP条件
RewriteCond %{REMOTE_ADDR} ^182\.198\.18\.(.*)$
RewriteRule ^/(.*)$ /www/wwwroot/80zx.com/$1 [L]
#第3个IP条件
RewriteCond %{REMOTE_ADDR} ^119\.183\.8\.(.*)$
RewriteRule ^/(.*)$ /www/wwwroot/80zx.com/$1 [L]
实际Apache配置文件参考
<VirtualHost *:80>
ServerAdmin webmaster@example.com
DocumentRoot "/www/wwwroot/80zx.cn"
ServerName abc.80zx.cn
ServerAlias 80zx.cn www.80zx.cn
#errorDocument 404 /404.html
ErrorLog "/www/wwwlogs/80zx.cn-error_log"
CustomLog "/www/wwwlogs/80zx.cn-access_log" combined
#重点开始
RewriteEngine On
# 检查是否为手机端访问
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^/(.*)$ /www/wwwroot/mobile/$1 [L]
#第一个IP条件
RewriteCond %{REMOTE_ADDR} ^119\.128\.128\.28$
RewriteRule ^/(.*)$ /www/wwwroot/80zx.com/$1 [L]
#第二个IP条件
RewriteCond %{REMOTE_ADDR} ^182\.198\.18\.(.*)$
RewriteRule ^/(.*)$ /www/wwwroot/80zx.com/$1 [L]
#第3个IP条件
RewriteCond %{REMOTE_ADDR} ^119\.183\.8\.(.*)$
RewriteRule ^/(.*)$ /www/wwwroot/80zx.com/$1 [L]
#重点结束
#DENY FILES
<Files ~ (\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md)$>
Order allow,deny
Deny from all
</Files>
#PHP
<FilesMatch \.php$>
SetHandler "proxy:unix:/tmp/php-cgi-00.sock|fcgi://localhost"
</FilesMatch>
#PATH
<Directory "/www/wwwroot/80zx.cn">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
</Directory>
<Directory "/www/wwwroot/80zx.com">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
</Directory>
<Directory "/www/wwwroot/mobile">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
</Directory>
<Directory "/www/wwwroot/pc">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
</Directory>
</VirtualHost>
本文详细介绍两种让 PhpStudy 在 Windows 开机后自动启动的方法,包括使用启动文件夹批处理脚本和直接注册 Apache、MySQL 为系统服务,助你减少重复操作,提高开发效率。
本文详细介绍如何在不重装 PHPStudy 的情况下,通过修改 Apache/Nginx、MySQL、PHP 配置文件实现网站搬家。针对 MySQL 数据目录错误、PHP 扩展路径错误等常见问题,提供快速定位与解决方法,帮助开发者轻松迁移开发环境。
最近使用thinkphp6获取参数会附加上链接路径,造成插入数据报错Options +FollowSymlinks -MultiviewsRewriteEngine onRewriteCond %{R...
0x01 问题现象有时再用xdebug调试程序时,由于调试时间过长会出现500服务器错误的现象,根本原因在于apache默认的连接时间过短导致。0x02 适应于中间件:Apache(Fastcgi)错...
Apache解决虚拟主机无法指定绑定Public目录伪静态设置方法
引言基于Laravel Framework version Lumen (5.2.9)的项目中的 tymon/jwt-auth 验证不生效,检查过后发现是 Apache 抛弃了 Authorizati...