Nginx + Magento在子文件夹中

我看了一下这里的相关话题,但是对我来说并没有把握。 所以这就是我正在做的。 我们正在从一台服务器转移到另一台服务器。 老一个运行Apache,新运行的是Nginx。 所以对于我们的一个网站,我们在http://mydomain.com上有一个WordPress的CMS网站,在http://mydomain.com/shop上有一个Magento安装

CMS运行没有问题。 如果说到店里我就卡住了。 显示Magento index.php – 迄今为止都是很好的。 但只要我试图在商店的其他地方导航,我遇到了404错误。 所以在重写时一定会有一些错误。 我尝试了很多没有用的东西。

所以这里来了我目前的虚拟主机configuration:

server { listen 80; listen 443; server_name www.domain.de domain.de *.domain.de; root /var/www/domain.de/www.domain.de/htdocs; index index.php; access_log /var/log/nginx/domain_access.log; error_log /var/log/nginx/domain_error.log; error_page 403 /403.php; error_page 404 /404.php; error_page 500 /500.php; error_page 501 /500.php; error_page 502 /500.php; error_page 503 /500.php; location ~* \.(js|css|jpg|jpeg|gif|png|ico|swf)$ { if (-f $request_filename) { expires 30d; add_header Cache-Control "public"; break; } } #Temp-Dateien blocken location ~* \.(bak|cache|csv|git|old|php~|spool|svn|swp|temp|tmp)$ { deny all; } #Sonstige Dateien blocken location ~* \.(1st|386|app|ani|asm|bat|bin|cfg|cmd|cnf|com|cpl|dbs|dll|drv|exe|inc|sh|lnk|reg|scr|sys|vxd)$ { deny all; } location / { try_files $uri $uri/ /index.php?$args; } location /shop { index index.html index.php; try_files $uri $uri/ @handler; expires 30d; } location ~ ^/(app|includes|lib|media/downloadable|pkginfo|report/config.xml|var)/ { internal; } location /var/export/ { internal; } location /. { return 404; } location @handler { rewrite /shop/ /index.php; } location ~* .php/ { rewrite ^(.*.php)/ www last; } location ~ ^/(gpack|img|tmp/map)/ { allow all; } location ~ .*\.php?$ { fastcgi_pass unix:/var/run/php/domain.de.sock; fastcgi_index index.php; include conf/fastcgi.conf; } } 

任何提示是值得欢迎的。 我想这一定是我的一个小错误。

提前致谢。 问候,史蒂文

*编辑*

好吧,我解决了。 这是我目前的配置文件。

 server { listen 80; listen 443; server_name www.domain.de domain.de *.domain.de; root /var/www/domain.de/www.domain.de/htdocs; index index.php; access_log /var/log/nginx/domain_access.log; error_log /var/log/nginx/domain_error.log; error_page 403 /403.php; error_page 404 /404.php; error_page 500 /500.php; error_page 501 /500.php; error_page 502 /500.php; error_page 503 /500.php; location ~* \.(js|css|jpg|jpeg|gif|png|ico|swf)$ { if (-f $request_filename) { expires 30d; add_header Cache-Control "public"; break; } } #Temp-fileen blocken location ~* \.(bak|cache|csv|git|old|php~|spool|svn|swp|temp|tmp)$ { deny all; } #Sonstige fileen blocken location ~* \.(1st|386|app|ani|asm|bat|bin|cfg|cmd|cnf|com|cpl|dbs|dll|drv|exe|inc|sh|lnk|reg|scr|sys|vxd)$ { deny all; } location / { try_files $uri $uri/ /index.php?$args; } 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; } location ~ ^/(gpack|img|tmp/map)/ { allow all; } location ~ .*\.php?$ { fastcgi_pass unix:/var/run/domain.de.sock; fastcgi_index index.php; include conf/fastcgi.conf; } } 

希望它也能帮助别人。 感谢您的支持。