有使用zend框架的网页。网络实际上使用重写。我搜索了解决方案如何设置zend框架win nginx ..他们说没有必要将那些默认重写.htaccess转换为nginx one ..
无论如何这里是.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
RewriteRule ^robots\.txt$ robots.txt
这是网页的nginx配置:
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
root /var/www/vhosts/domain.lt/httpdocs;
index index.php;
# Make site accessible from http://localhost/
server_name domain.lt;
server_name www.domain.lt;
location / {
if (-f $request_filename) {
root /var/www/vhosts/domain.lt/httpdocs;
}
}
location ~* ^/(favicon.ico|robots.txt)$ {
access_log off;
log_not_found off;
}
error_page 404 = /index.php;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/www;
#}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /var/www/vhosts/domain.lt/httpdocs/index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
location ~* \.(css|js|jpeg|jpg|gif|png|ico|xml)$ {
access_log off;
expires 30d;
}
}
最后错误本身:
2013/02/03 01:52:13 [error] 12293#0: *29 open() "/var/www/vhosts/domain.lt/httpdocs/daiktai/kategorija/slaugos-ir-higienos-priemones/page/147" failed (2: No such file or directory), client: 66.249.75.237, server: domain.lt, request: "GET /daiktai/kategorija/slaugos-ir-higienos-priemones/page/147 HTTP/1.1", host: "www.domain.lt"
正如您所看到的,nginx将每次重写视为文件条目,当然 - 不存在。我该如何解决这个问题?网页实际上很好,没有重写。
我的问题是:如何从error.log中删除这些错误,我是否需要将该htaccess文件转换为nginx重写?如果可以的话请转换一下吗?我尝试了一些在线转换器 - RewriteCond
和RewriteRule
完全被忽略。
答案 0 :(得分:0)
找到解决方案:
这整个部分是错误的
location / {
if (-f $request_filename) {
root /var/www/vhosts/domain.lt/httpdocs;
}
}
我刚将其添加到server
try_files $uri $uri/ /index.php;
这是location ~ \.php$
try_files $uri =404;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;