Welcome! Log In Create A New Profile

Advanced

Rewrite locate for subdirectories for installing magento software

Posted by nginxx 
Rewrite locate for subdirectories for installing magento software
June 17, 2011 01:20PM
I like to install magento shop software on my nginx server in a subdirectory. Magento suggests this for installing it in /, but I want to install magento in /shop/. I need to do all these things for /shop/ and not for root as I already have a forum on root. have no clue what to do with things like location ~ .php$ . I think location ~ /shop/.php$ won't do it at all, right? Thanks for your help !!

http://www.magentocommerce.com/wiki/1_-_installation_and_configuration/configuring_nginx_for_magento#global_configuration
-----------------------------------------------------------------------------------------------------------------------
[quote]server {
listen 80;
server_name DOMAIN.com;
rewrite / $scheme://www.$host$request_uri permanent; ## Forcibly prepend a www
}

server {
listen 80 default;
## SSL directives might go here
server_name www.DOMAIN.com *.DOMAIN.com; ## Domain is here twice so server_name_in_redirect will favour the www
root /var/www/vhosts/DOMAIN.com;

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
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 /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 /. { ## Disable .htaccess and other hidden files
return 404;
}

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 127.0.0.1:9000;
fastcgi_param HTTPS $fastcgi_https;
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
}
}
--------------------------------------------------------------------



Edited 1 time(s). Last edit at 06/17/2011 01:21PM by nginxx.
Re: Rewrite locate for subdirectories for installing magento software
June 19, 2011 07:12AM
Is this too specific? Or could someone help me where to look and learn about it? Thanks!!!
Re: Rewrite locate for subdirectories for installing magento software
June 20, 2011 10:26AM
Hello nginxx,
I came to have the same problem as I was used to install php applications into a [url=non-root]http://wiki.nginx.org/NonRootWebPathApacheStyle[/url] directory. I worked around this problem like so. This [b]redirects[/b] everything from host/app to app.host:

server {
server_name host;
rewrite ^/app(/.*)?$ http://app.host$1 permanent;
....
# Then create a separate server section for app.host...

I know this might be unsatisfying, as you need to create subdomains... It works for me though and I'm happy with it. Please thoroughly test before usage, also note that the permanent argument makes your browser store the redir info forever, so create a new browser profile or delete browsing history when testing/retesting
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 199
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready