我在Wordpress下运行magento(根目录上的Wordpress和子目录下的mangento" / shop")。以前我在Apache下运行它,所以在/ shop文件夹下单独的.htaccess运行正常。
当我将服务器移到NginX上时,所有内部magento URL都显示为404.请帮我解决这个问题。请建议我如何使用Wordpress在/ shop文件夹下运行Magento。
这是我的NginX配置文件:
server {
listen 80;
server_name domain.com www.domain.com;
root /var/www/html;
index index.php index.html index.htm;
error_log /var/www/logs/error.log;
access_log /var/www/logs/access.log;
### gZip Setting ###
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
### gZip End ###
location / {
if ($http_host !~ "^www\."){
rewrite ^(.*)$ http://www.$http_host/$1 redirect;
}
try_files $uri $uri/ =404;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location /shop/ {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
if (!-e $request_filename)
{
rewrite ^(.+)$ /index.php?q=$1 last;
}
location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
expires off; ## Do not cache dynamic content
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
}
答案 0 :(得分:0)
我得到了解决方案,这是我的新配置文件:
server {
listen 80;
server_name domain.com www.domain.com;
root /var/www/html;
index index.php index.html index.htm;
error_log /var/www/logs/domain-error-ssl.log;
access_log /var/www/logs/domain-access-ssl.log;
### gZip Setting ###
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
### gZip End ###
location / {
if ($http_host !~ "^www\."){
rewrite ^(.*)$ https://www.$http_host/$1 redirect;
}
try_files $uri $uri/ /index.php?$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $1 last;
}
### Configuration for shop ###
location /shop {
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
if ($uri ~ "^/index.php/admin.*$"){
rewrite ^/index.php/admin(.*) /admin$1 redirect;
}
}
location ~ ^/shop/(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; }
location /shop/var/export/ { internal; }
location @handler { rewrite / /shop/index.php; }
### END Configuration for shop ###
location ~ .php$ { ## Execute PHP scripts
expires off; ## Do not cache dynamic content
fastcgi_read_timeout 120;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
#fastcgi_param HTTPS $fastcgi_https;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
}