apache对thinkphp支持很好,只需要thinkphp目录下放置.htaccess文件即可,例如:
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
但是换到nginx会各种文件404,打不开等等
如下为nginx配置文件,直接复制粘粘修改
然后如果需要模式2(隐藏index.php) 在thinkphp的配置文件config.php中添加 ‘URL_MODEL‘ => ‘2‘
server {
listen 443 ssl;
server_name www.a.com;
root /home/www.a.com;
index index.html index.htm index.php;
ssl_certificate /tmp/server.crt;
ssl_certificate_key /tmp/server.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
if (!-e $request_filename) {
#如果是二级目录,xxx表示上层目录名
#rewrite ^/xxx/(.*)$ /xxx/index.php?s=$1 last;
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ \.php(.*)$ {
root /home/go.jinianri.com;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}