apache php 伪静态,php和apache伪静态的一些常用代码

1. htaccess中设置图片防盗链RewriteEngine on

##################################################

RewriteCond %{HTTP_REFERER} !^$

RewriteCond %{HTTP_REFERER} !^http://(www\.)?php.cn(/)?.*$ [NC]

RewriteRule .*\.(gif|jpg|jpeg|bmp|png)$ http://nothing_phpcn[R,NC,L]

##################################################################################

RewriteCond $1 !^(index\.php|statics|upload|app\.html|robots\.txt)

RewriteRule ^(.*)$ /index.php?/$1 [L]

2. htaccess设置404 500错误页ErrorDocument 404 /statics/home/notfound.html

ErrorDocument 500 /statics/home/notfound.html

3. phpstudy伪静态错误No input file specified解决办法

apache No input filespecified,今天是我们配置apache RewriteRule时出现这种问题,解决办法很简单如下

打开.htaccess 在RewriteRule 后面的index.php教程后面添加一个“?”

完整代码如下.htaccess

RewriteEngine on

RewriteCond $1 !^(index.php|images|robots.txt)

RewriteRule ^(.*)$ /index.php?/$1 [L]

4. Thinkphp非根目录无法加载模块.htaccess加RewriteBase /demo2/

\demo2\ThinkPHP\Library\Think\Dispatcher.class.php 119行

define('__INFO__',trim($_SERVER['PATH_INFO'],'/'));之前加:

$_SERVER['PATH_INFO']=str_replace('/demo2','',$_SERVER['PATH_INFO']);

5. CI框架伪静态iis-web.config配置参考<?xml version="1.0" encoding="UTF-8"?>

6. thinkphp伪静态 去除index.php

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-d

RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]

开启路由:

'URL_ROUTER_ON' => true, //URL路由

'URL_MODEL' => 2, // URL模式

7. httpd.ini与.htaccess伪静态规则转换

21837c905186b4bfa4ef6bfa8d812629.png

8. TP正则路由

config.php<?php

$conf_array=array(

/*加载额外配置文件*/

'LOAD_EXT_CONFIG' => 'db,htaccess',

.....

);

htaccess.php<?php

$rules=array(

'URL_ROUTER_ON' => true, //开启路由

'URL_ROUTE_RULES' => array( //定义路由规则

'/^verifycode\/(\w+)$/'=>'g=Index&c=Verifycode&a=index&type=:1', //验证码

'/^upload_image$/'=>'g=Index&c=Image&a=upload', //教程图片上传按钮

/*登录相关*/

'/^login\/login$/'=>'g=Index&c=Login&a=login', //登录

'/^login\/reg$/'=>'g=Index&c=Login&a=reg', //注册

'/^login\/logout$/'=>'g=Index&c=Login&a=logout', //登录

),

);

return $rules;

本文原创发布php中文网,转载请注明出处,感谢您的尊重!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值