作者:大家庭方不_402 | 来源:互联网 | 2022-12-09 11:26
我第一次尝试在MAMP中使用nginx服务器而不是用于Codeigniter的apache服务器.我将我的apache htaccess重写规则转换为nginx重写规则.但它显示的是我文件中的index.php文件代码而不是我的网站.这是我的apache htaccess规则,
DirectoryIndex index.php
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA]
这是我的nginx配置文件,
http {
include mime.types;
default_type text/html;
gzip on;
gzip_types text/css text/x-component application/x-Javascript application/Javascript text/Javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
sendfile on;
server {
listen 80 default_server;
# MAMP DOCUMENT_ROOT !! Don't remove this line !!
root "C:/MAMP/htdocs/aia_inventory/";
access_log C:/MAMP/logs/nginx_access.log;
error_log C:/MAMP/logs/nginx_error.log;
index index.html index.htm index.php;
#autoindex on;
#server_name localhost;
location ~/ {
#root C:/MAMP/htdocs/aia_inventory/;
#index index.html index.php;
try_files $uri $uri/ /index.php/$request_uri;
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
}
location ~* ^/(assets|files|robots\.txt) { }
location ~* /MAMP(.*)$ {
root C:/MAMP/bin;
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9100;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location ~* /phpMyAdmin(.*)$ {
root C:/MAMP/bin;
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9100;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location ~* /phpLiteAdmin(.*)$ {
root C:/MAMP/bin;
index phpliteadmin.php index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9100;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
location ~* /SQLiteManager(.*)$ {
root C:/MAMP/bin;
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9100;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
#location /icons {
# alias /Applications/MAMP/Library/icons;
# autoindex on;
#}
#location /favicon.ico {
# alias /Applications/MAMP/bin/favicon.ico;
# # log_not_found off;
# # access_log off;
#}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9100;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
#location ~ /\. {
# deny all;
#}
# location ~* \.(gif|jpg|png|pdf)$ {
# expires 30d;
# }
# location = /robots.txt {
# allow all;
# log_not_found off;
# access_log off;
# }
# location ~* \.(txt|log)$ {
# allow 127.0.0.1;
# deny all;
# }
# location ~ \..*/.*\.php$ {
# return 403;
# }
#location /nginx_status {
# stub_status on;
# access_log off;
# allow 127.0.0.1;
# deny all;
#}
}
}
我不明白我错过了哪里.我的规则是在apache服务器上工作.但是在nginx服务器上,它只显示index.php文件的原始代码.提前致谢.