我在这里查看了相关主题,但没有为我做这个伎俩.
所以这就是我正在做的事情.
我们目前正在从一台服务器转移到另一台服旧的运行Apache,新的运行Nginx.因此,对于我们的一个网站,我们在http://mydomain.com上有一个wordpress CMS站点
和http://mydomain.com/shop上的Magento安装
CMS运行没有问题.如果到了商店我就被困住了.显示了Magento index.PHP – 到目前为止一切都很好.但是当我尝试在商店的其他地方导航时,我遇到了404错误.所以必须在重写时出现一些错误.我尝试了许多无用的东西.
所以这是我当前的vhost配置:
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-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;
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;
}
}
希望它也有助于其他人.
感谢您的支持.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。