apache重写rul规则:
在public目录下创建.htaccess文件
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(.*\.php)/((?s).*)$ $1?_url=/$2 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L]
</IfModule>
nginx重写url规则:
server {
listen 80;
server_name 域名;
root web目录;
index index.php index.html index.htm;
charset utf-8;
location ~ [^/]\.php(/|$) {
#与你的php-fpm.conf配置保持一致
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#添加项目目录
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/:/home/wwwroot/myphalcon/";
#include pathinfo.conf;
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
try_files $fastcgi_script_name =404;
}
location / {
try_files $uri /index.php?_url=$uri&$args;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
expires 30d;
}
location ~ .*\.(js|css)?$ {
expires 12h;
}
location ~ /\. {
deny all;
}
}