我在nginx服务上运行的网站有问题,我的网址是daunhotdongluc.com。网址错误只是在点击任何网址时加载主页,我认为它与.htaccess文件或nginx配置有关。
我尝试转换默认的.htaccess
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
DirectoryIndex index.php [L]
RewriteRule ^admin/$ admin/index.php [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)-([0-9]+).html$ index.php?com=$1&id=$2&id_cur=$3 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)-([0-9]+)/$ index.php?com=$1&idc=$2&id_cur=$3 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)-([0-9]+)/p=([0-9]+)$ index.php?com=$1&idc=$2&id_cur=$3&p=$4 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+).html$ index.php?com=$1&id=$2 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ index.php?com=$1&idc=$2 [L]
RewriteRule ^([a-zA-Z0-9_-]+).html$ index.php?com=$1 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?com=$1 [L]
RewriteRule ^([a-zA-Z0-9_-]+)/p=([0-9]+)$ index.php?com=$1&p=$2 [L]
RewriteRule ^([a-zA-Z0-9_-]+).html(.*)$ index.php?com=$1$2 [L]
到
location / {
# nginx configuration
index index.php [L];
location / {
if ($http_host ~* "^www\.(.*)$"){
rewrite ^(.*)$ http://%1/$1 redirect;
}
rewrite ^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)-([0-9]+).html$ /index.php?com=$1&id=$2&id_cur=$3 break;
rewrite ^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)-([0-9]+)/$ /index.php?com=$1&idc=$2&id_cur=$3 break;
rewrite ^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)-([0-9]+)/p=([0-9]+)$ /index.php?com=$1&idc=$2&id_cur=$3&p=$4 break;
rewrite ^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+).html$ /index.php?com=$1&id=$2 break;
rewrite ^/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/$ /index.php?com=$1&idc=$2 break;
rewrite ^/([a-zA-Z0-9_-]+).html$ /index.php?com=$1 break;
rewrite ^/([a-zA-Z0-9_-]+)/$ /index.php?com=$1 break;
rewrite ^/([a-zA-Z0-9_-]+)/p=([0-9]+)$ /index.php?com=$1&p=$2 break;
rewrite ^/([a-zA-Z0-9_-]+).html(.*)$ /index.php?com=$1$2 break;
}
location = /admin {
rewrite ^(.*)$ /admin/index.php break;
}
}
这是我的Nginx配置文件:
server {
listen 80;
server_name www.daunhotdongluc.com;
rewrite ^(.*) http://daunhotdongluc.com$1 permanent;
}
server {
listen 80;
# access_log off;
access_log /home/daunhotdongluc.com/logs/access.log;
# error_log off;
error_log /home/daunhotdongluc.com/logs/error.log;
root /home/daunhotdongluc.com/public_html;
index index.php index.html index.htm;
server_name daunhotdongluc.com;
location / {
try_files $uri $uri/ /index.php?$args;
}
# Custom configuration
include /home/daunhotdongluc.com/public_html/*.conf;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 32k;
fastcgi_buffers 8 16k;
fastcgi_busy_buffers_size 32k;
fastcgi_temp_file_write_size 32k;
fastcgi_intercept_errors on;
fastcgi_param SCRIPT_FILENAME /home/daunhotdongluc.com/public_html$fastcgi_script_name;
}
# Disable .htaccess and other hidden files
location ~ /\.(?!well-known).* {
deny all;
access_log off;
log_not_found off;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~* \.(3gp|gif|jpg|jpeg|png|ico|wmv|avi|asf|asx|mpg|mpeg|mp4|pls|mp3|mid|wav|swf|flv|exe|zip|tar|rar|gz|tgz|bz2|uha|7z|doc|docx|xls|xlsx|pdf|iso|eot|svg|ttf|woff)$ {
gzip_static off;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
access_log off;
expires 30d;
break;
}
location ~* \.(txt|js|css)$ {
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
access_log off;
expires 30d;
break;
}
}
我尝试了很多次来修复此错误,但未成功。 感谢您的帮助!
答案 0 :(得分:0)
任何建议解决此错误?! 谢谢!