【发布时间】:2015-07-16 06:57:18
【问题描述】:
在根目录我有 Drupal。在子目录中我有 Magento。很可能是 drupal 重写与 magento 重写重叠。
无需任何 nginx 配置即可成功打开 Magento 主页,但链接不起作用。
我不确定,但我认为要解决问题,我需要从 drupal 路由中排除 magento 目录。
另一件事是,我不确定我是否有正确的 magento 配置。
根配置:
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 配置
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
}
【问题讨论】:
标签: magento drupal nginx rewrite subdirectory