ThinkPHP3.2多域名 Virtual .htaccess 匹配 RewriteCond %{HTTP_HOST}

本文介绍如何使用Apache服务器通过配置文件设置不同类型的文件缓存策略,并利用重写规则进行URL重定向及路径匹配,提高网站访问速度。
<Files *>
   Options -Indexes
</Files>


<IfModule mod_headers.c>
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=2592000, public"
</FilesMatch>
<FilesMatch "\.(xml|txt)$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
<FilesMatch "\.(html|htm|php|shtml)$">
Header set Cache-Control "max-age=86400"
</FilesMatch>
</IfModule>


<IfModule mod_rewrite.c>
  Options +FollowSymlinks
  RewriteEngine On

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^([a-zA-Z0-9_]{2,32}\.(xml|html|txt)) seo.php?file=$1 [L]

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !(.*)/$
#  RewriteCond %{REQUEST_URI} !\.html$
  RewriteRule ^(.*)$ /$1/ [L,R=301]

  RewriteCond %{HTTP_HOST} ^google.com [NC]
  RewriteRule ^(.*)$ http://www.google.com/$1 [L,R=301]

  RewriteCond %{HTTP_HOST} !^(loc|localhost|devwww|192.168.) [NC]
  RewriteCond %{HTTP_HOST} !(google.com)$ [NC]
  RewriteRule ^(.*)$ http://www.google.com/$1 [L,R=301]

  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

</IfModule>

#兼容网站 google.com、work.google.com、admin.google.com 全部指向同一个目录程序#

实现:
#如果是google.com 访问,直接跳转到 www.google.com/$1
#如果是my.google.com、test.google.com 不跳转
#如果是localhost、192.168.*.*、loc、devwww本地测试的环境,不跳转
#其他全部跳转


[Sun Jun 29 14:55:13.531112 2025] [core:error] [pid 27208:tid 1168] [client ::1:61472] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use &#39;LimitInternalRecursion&#39; to increase the limit if necessary. Use &#39;LogLevel debug&#39; to get a backtrace. [Sun Jun 29 14:56:16.227311 2025] [core:error] [pid 27208:tid 1148] [client ::1:61485] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use &#39;LimitInternalRecursion&#39; to increase the limit if necessary. Use &#39;LogLevel debug&#39; to get a backtrace. [Sun Jun 29 15:04:18.703894 2025] [core:warn] [pid 35516:tid 364] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run? [Sun Jun 29 15:04:18.862470 2025] [mpm_winnt:notice] [pid 35516:tid 364] AH00455: Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 configured -- resuming normal operations [Sun Jun 29 15:04:18.862470 2025] [mpm_winnt:notice] [pid 35516:tid 364] AH00456: Apache Lounge VS17 Server built: Oct 18 2023 13:03:18 [Sun Jun 29 15:04:18.862470 2025] [core:notice] [pid 35516:tid 364] AH00094: Command line: &#39;c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache&#39; [Sun Jun 29 15:04:18.873441 2025] [mpm_winnt:notice] [pid 35516:tid 364] AH00418: Parent: Created child process 37656 [Sun Jun 29 15:04:21.226512 2025] [mpm_winnt:notice] [pid 37656:tid 320] AH00354: Child: Starting 64 worker threads. [Sun Jun 29 15:07:19.452902 2025] [core:warn] [pid 29396:tid 396] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run? [Sun Jun 29 15:07:19.567596 2025] [mpm_winnt:notice] [pid 29396:tid 396] AH00455: Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 configured -- resuming normal operations [Sun Jun 29 15:07:19.567596 2025] [mpm_winnt:notice] [pid 29396:tid 396] AH00456: Apache Lounge VS17 Server built: Oct 18 2023 13:03:18 [Sun Jun 29 15:07:19.567596 2025] [core:notice] [pid 29396:tid 396] AH00094: Command line: &#39;c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache&#39; [Sun Jun 29 15:07:19.579564 2025] [mpm_winnt:notice] [pid 29396:tid 396] AH00418: Parent: Created child process 37736 [Sun Jun 29 15:07:21.852612 2025] [mpm_winnt:notice] [pid 37736:tid 332] AH00354: Child: Starting 64 worker threads. [Sun Jun 29 15:07:32.462402 2025] [core:error] [pid 37736:tid 1180] [client ::1:61597] AH00126: Invalid URI in request &#39;index.php&#39; &#39;GET /web/UserLogin/accountLogin HTTP/1.1&#39; [Sun Jun 29 15:07:50.674094 2025] [core:error] [pid 37736:tid 1176] [client ::1:61598] AH00126: Invalid URI in request &#39;index.php&#39; &#39;GET /web/UserLogin/accountLogin HTTP/1.1&#39; [Sun Jun 29 15:08:28.424576 2025] [core:warn] [pid 25176:tid 336] AH00098: pid file C:/xampp/apache/logs/httpd.pid overwritten -- Unclean shutdown of previous Apache run? [Sun Jun 29 15:08:28.539271 2025] [mpm_winnt:notice] [pid 25176:tid 336] AH00455: Apache/2.4.58 (Win64) OpenSSL/3.1.3 PHP/8.2.12 configured -- resuming normal operations [Sun Jun 29 15:08:28.539271 2025] [mpm_winnt:notice] [pid 25176:tid 336] AH00456: Apache Lounge VS17 Server built: Oct 18 2023 13:03:18 [Sun Jun 29 15:08:28.539271 2025] [core:notice] [pid 25176:tid 336] AH00094: Command line: &#39;c:\\xampp\\apache\\bin\\httpd.exe -d C:/xampp/apache&#39; [Sun Jun 29 15:08:28.574179 2025] [mpm_winnt:notice] [pid 25176:tid 336] AH00418: Parent: Created child process 12320 [Sun Jun 29 15:08:30.762870 2025] [mpm_winnt:notice] [pid 12320:tid 352] AH00354: Child: Starting 64 worker threads. [Sun Jun 29 15:09:23.908308 2025] [core:error] [pid 12320:tid 1184] [client ::1:61618] AH00126: Invalid URI in request &#39;index.php&#39; &#39;GET /web/Index/thinkPHP8 HTTP/1.1&#39;
最新发布
06-30
达梦DM数据库是国内自主研发的高性能数据库管理系统,而ThinkPHP是一个快速、简单的面向对象的轻量级PHP开发框架。为了能够使ThinkPHP与达梦DM数据库配合使用,在两者之间需要构建合适的驱动程序。 `Dm.class.php`即是在ThinkPHP 3.2版本下用于连接并操作达梦DM数据库的一个自定义驱动类文件。此驱动通过PDO(PHP Data Objects)或其他适合的方式为应用程序提供了一套API接口以便于对DM数据库进行诸如查询、更新等数据交互活动。它实现了对ThinkPHP底层模型层对于不同类型的SQL语法支持,并适配了达梦特有的配置项及功能特性。 以下是关于如何创建和理解这个驱动的一些关键点: ### 创建步骤 1. **环境准备** 确保已经安装好了达梦数据库客户端以及相应的PHP PDO扩展;同时确认你的项目基于ThinkPHP 3.2版搭建完成。 2. **编写代码结构** ```php class Dm extends Db { // 构造函数可以在这里添加特定初始化内容 public function query($sql,$vars=array()) { // 实现针对DM SQL查询的具体处理逻辑... } protected function initConnect() { // 初始化链接部分, 包含错误检查等必要设置 } // 其他如exec(), fetchOne(), close()等相关方法也需要相应地重写以适应DM特点 } ``` 3. **集成到框架内** 将上述驱动放置于合适的位置(例如`\Think\Db\Driver\Dm.class.php`),并且调整应用配置使得默认使用的数据库类型指向该新驱动。 4. **测试验证** 最后,利用已有的表单提交或命令行工具来进行实际的数据访问测试,确保所有增删改查的操作都能正常工作无误后便可正式投入使用。 ### 使用注意事项 - 因各厂商提供的SQL标准可能存在差异,请务必查阅官方文档了解其特殊之处; - 对于大型项目的迁移建议逐步替换旧有组件而非一次性大换血; - 若遇到性能瓶颈,则需考虑优化索引建立、缓存策略等方面因素。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值