apache下只用。htaccess
RewriteEngine on
RewriteCond $1 !^(index\.php|css|themes|images|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
nginx不支持rewriteCond,nginx配置方法:
server {
listen 80;
server_name act;
location / {
root D:/ci_act;
index index.html index.htm index.php;
autoindex on;
rewrite ^/$ /index.php last;
rewrite ^/(?!index\.php|css|themes|images|robots\.txt)(.*)$ /index.php/$1 last;
}
location ~ ^(.+\.php)(.*)$ {
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 PATH_TRANSLATED D:/ci_act$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME D:/ci_act$fastcgi_script_name;
include fastcgi_params;
}
}
本文详细解析了Apache与Nginx在使用.htaccess文件进行重定向规则设置的区别,包括如何在不同场景下高效实现网页重定向。
1249

被折叠的 条评论
为什么被折叠?



