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程序目錄