在根目录中我有Drupal。在子目录中我有Magento。最有可能是drupal重写重叠的magento重写。
Magento主页在没有任何nginx配置的情况下成功打开,但链接无法正常工作。
我不确定,但我想解决我需要从drupal路由中排除magento目录的问题。
另一件事是,我不确定我是否有适当的magento配置。
root config:
server {
listen 80;
root /var/www/domain;
index index.php index.html index.htm;
server_name domain.com;
location /fe {
proxy_pass http://domain.com:1234/visualization;
}
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/domain;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9$
location ~ \.php$ {
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
magento config
server {
listen 80;
## SSL directives might go here
server_name domain.com; ## Domain is here twice so server_name_in_redirect will favour the www
root /var/www/domain/magento;
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
# try_files $uri $uri/ /index.php?q=$uri&$args;
expires 30d; ## Assume all files are cachable
}
## These locations would be hidden by .htaccess normally
location ^~ /app/ { deny all; }
location ^~ /includes/ { deny all; }
location ^~ /lib/ { deny all; }
location ^~ /media/downloadable/ { deny all; }
location ^~ /pkginfo/ { deny all; }
location ^~ /report/config.xml { deny all; }
location ^~ /var/ { deny all; }
## location ~ /\.ht { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
## location /.
location ~ /\.ht { ## Disable .htaccess and other hidden files
return 404;
}
location /api {
rewrite ^/api/rest /api.php?type=rest last;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ $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/php5-fpm.sock;
## fastcgi_pass 127.0.0.1:8079;
##fastcgi_read_timeout 10800s;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
答案 0 :(得分:2)
最好的方法是使用magento的某个子域,例如https://shop.yourdomain.com。但是如果你想把它保持为http://yourdomain.com/magento,你需要为Magento删除单独的nginx配置文件,并将/ magento / location添加到root配置。我的意思是:
location /magento/ {
root /var/www/domain/magento; #main thing
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
location ^~ /magento/app/ { deny all; }
location ^~ /magento/includes/ { deny all; }
location ^~ /magento/lib/ { deny all; }
location ^~ /magento/media/downloadable/ { deny all; }
location ^~ /magento/pkginfo/ { deny all; }
location ^~ /magento/report/config.xml { deny all; }
location ^~ /magento/var/ { deny all; }
location ~ /magento/\.ht { deny all; }
etc.
然后您需要检查Magento Secure / Unsecure URL。它应该是http://yourdomain.com/magento/您可以通过管理面板或直接在数据库(core_config_data表)中进行更改。最后清除缓存并重新启动Nginx。