php伪静态nginx
‘壹’ nginx服务器伪静态php动态文件名提升目录怎样写规则
location/count.php{
fastcgi_pass127.0.0.1:9000;
fastcgi_paramSCRIPT_FILENAME$document_root/aaa/bbb/viewhits.php;
includefastcgi_params;
}
这样应该可以。
‘贰’ thinkphp 3.2 nginx配置伪静态PUBLIC目录变成控制器如图,求高手指点
ThinkPHP中默认的URL地址是形如这样的:http://localhost/Myapp/index.php/Index/index/
Myapp是我的项目文件名,默认的访问地址是上面这样的。为了使URL更加简介友好,现在要去掉中间的index.php,方法如下:
1。确认httpd.conf配置文件中加载了mod_rewrite.so 模块,加载的方法是去掉mod_rewrite.so前面的注释#号
2。讲httpd.conf中的Allowoverride None 将None改为All
3。打开对应的项目配置文件,我的项目配置文件是Myapp/Conf/config.php ,在这个配置文件数组中增加一行,‘URL_MODEL’=>2
4。在项目的根目录下面建立一个.htaccess文件,里面写入下面的内容:
<IfMole rewrite_mole>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfMole>
如果你的服务器支持rewrite,现在就可以通过http://localhost/Myapp/Index/index/访问Index模块下面的index操作。
‘叁’ 如何实现网站的伪静态,分别说一下nginx和apache的实现方式
Nginx下设置伪静态方法与Apache差不多,直接在nginx.conf (或者在对应的*.conf) 中找到需设置伪静态规则的服务器对应字段,在server{ location/{ } }中添加以下代码:
server{
listen80default_server;
server_name_;
location/{
root/usr/share/nginx/html;
indexindex.htmlindex.htm;
rewrite^(.*)list-([0-9]+)-([0-9]+).html$$1list.php?page=$2&id=$3;
}
}
添加后重启Nginx服务即可生效
apache
要使用httpd.conf文件来设置伪静态策略,我们可以直接在httpd.conf中写入如下代码,如果您的网站是配置在VirtualHost中,则将这段代码加到对应的<VirtualHost hostname>
<VirtualHost>
标签内:
<IfMolemod_rewrite.c>
#输入:list-123-456.html
#输出:list.php?page=123&id=456
RewriteEngineon
RewriteRule^(.*)list-([0-9]+)-([0-9]+).html$$1list.php?page=$1&id=$2
</IfMole>
添加完成后重启httpd服务后即可生效
‘肆’ 如何配置nginx伪静态以支持ThinkPHP的PATHINFO模式
首先你的项目的config文件中要配置这一项
'URL_MODEL'
=>
2,
//
rewrite
在服务器中切换到nginx的安装目录,我这里是
/usr/local/nginx。然后添加thinkphp.conf
文件
vim
/usr/local/nginx/conf/thinkphp.conf
内容如下
location
/
{
if
(!-e
$request_filename){
rewrite
^/(.*)$
/index.php?s=/$1
last;
}
}
然后在你的配置文件中include一下刚刚的配置文件。
如果你的ThinkPHP入口文件index.php不在根目录,则需要把thinkphp.conf改成这样
location
/入口文件所在目录/
{
if
(!-e
$request_filename){
rewrite
^/abc/(.*)$
/abc/index.php?s=/$1
last;
}
}
‘伍’ phpcms伪静态在nginx怎么写
location / {
###以下为PHPCMS 伪静态化rewrite规则
rewrite ^(.*)show-([0-9]+)-([0-9]+)\.html$ $1/show.php?itemid=$2&page=$3;
rewrite ^(.*)list-([0-9]+)-([0-9]+)\.html$ $1/list.php?catid=$2&page=$3;
rewrite ^(.*)show-([0-9]+)\.html$ $1/show.php?specialid=$2;
####以下为PHPWind 伪静态化rewrite规则
rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;
}
‘陆’ nginx+apache+php+mysql组合应该怎么配置伪静态
先确定服务器是否支持Rewrite
比如是apache的话,
找到#LoadMole rewrite_mole moles/mod_rewrite.so
把前面的#去掉
保存并重启
然后在站点更目录下建立一个.htaccess文件,并写上伪静态规则即可!
如果是iis的话,有点麻烦,需要给iis安装一个伪静态组件,这个组件要钱的!
其他服务器的话,没用过,也没研究过!
‘柒’ Nginx伪静态php设置方法
修改/etc/nginx/nginx.conf,tae的话可能在conf.d里边的virtual.conf,在server里边添加伪静态规则
python">location/{
indexindex.phpindex.htmlindex.htm;
rewrite^(.*)/item/([0-9]+).html$1/item.php?id=$2last;
}
大概是这样,规则要自己测试
‘捌’ thinkphp 伪静态 nginx 规则怎么设置
关于nginx的伪静态设置(案例)
server {
listen 80;
server_name localhost;
index index.html index.htm index.php;
root /alidata/www/;
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?s=/$1 last;
}
}
location ~ .*.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
# 以下是为了让Nginx支持PATH_INFO
set $path_info "";
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param script_FILENAME $document_root$real_script_name;
fastcgi_param script_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_connect_timeout 120;
fastcgi_send_timeout 120;
fastcgi_read_timeout 120;
fastcgi_buffers 8 128K;
fastcgi_buffer_size 128K;
}
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*.(js|css)?$
{
expires 1h;
}
#伪静态规则
access_log /alidata/log/nginx/access/default.log;
}
‘玖’ phpStudy中nginx建DZ2.5怎么设置伪静态怎么都不成功
关于伪静态技术,最初是动态语言出现后为了解决用户访问的便利性和搜索蜘蛛的友好性。关于伪静态的组件有ISAPI_Rewrite、开源的IIRF等。但ISAPI_Rewrite Lite版只支持全局的httpd.conf的,不支持分布式的httpd.ini的,只有收费的Full版才支持分布式httpd.ini。现在我们知道,Nginx也能实现简单的伪静态。更多介绍伪静态可以参考
CI在Apache、Nginx上运行需要.htaccess配置文件,在IIS服务器上则需要web.config文件,CI的伪静态我们可以通过.htaccess里面的规则设定
RewriteEngine on
RewriteCond $1 !^(index\\.php|system\\.php|images|skin|js|ls|swfupload|attachment|application|robots\\.txt)
RewriteRule ^(.*)$ /fx/index.php/$1 [L]
注: RewriteRule ^(.*)$ /webdir/index.php/$1 [L]里的webdir是你的CI程序目录