rewrite rule needed for subdomains
Mike Smith
lists at ruby-forum.com
Wed Nov 4 21:10:09 MSK 2009
Igor Sysoev wrote:
> On Tue, Nov 03, 2009 at 10:19:09PM +0100, Mike Smith wrote:
>
>> >
>> > server {
>> > # a catchall server for "listen 80",
>> > # since it's "default" server for "listen 80"
>> >
>> > listen 80 default;
>> > server_name store1.domain.com;
>> >
>> > location / {
>> > rewrite ^ http://$host/magento/$request_uri? last;
>
> Probably, you need
>
> - rewrite ^ http://$host/magento/$request_uri? last;
> + rewrite ^ /magento$uri last;
When I do that and hit the following url
http://www.domain.com/magento/shop/by/expert
I see the following in the log
2009/11/04 13:07:38 [error] 22578#0: *1 rewrite or internal redirection
cycle while processing "/magento/magento/shop/by/expert", client:
127.0.0.1, server: _, request: "GET /magento/shop/by/expert HTTP/1.1",
host: "www.domain.com", referrer: "http://www.domain.com/"
Here is my config
#######################################################################
#
# This is the main Nginx configuration file.
#
# More information about the configuration options is available on
# * the English wiki - http://wiki.nginx.org/Main
# * the Russian documentation - http://sysoev.ru/nginx/
#
#######################################################################
#----------------------------------------------------------------------
# Main Module - directives that cover basic functionality
#
# http://wiki.nginx.org/NginxHttpMainModule
#
#----------------------------------------------------------------------
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
pid /var/run/nginx.pid;
#----------------------------------------------------------------------
# Events Module
#
# http://wiki.nginx.org/NginxHttpEventsModule
#
#----------------------------------------------------------------------
events {
worker_connections 1024;
}
#----------------------------------------------------------------------
# HTTP Core Module
#
# http://wiki.nginx.org/NginxHttpCoreModule
#
#----------------------------------------------------------------------
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local]
"$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
upstream backend {
server 127.0.0.1:9000;
}
#
# The default server
#
server {
listen 80;
server_name _;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /var/www/vhosts/domain.com/html;
index index.php;
if ($request_uri ~* "\.(ico|css|js|gif|jpe?g|png)$") {
expires max;
}
}
location /magento/ {
# rewrite - if file not found, pass it to the backend
if (!-f $request_filename) {
rewrite ^ /magento$request_uri last;
break;
}
}
# pass the PHP scripts to FastCGI server listening on
127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
/var/www/vhosts/domain.com/html/$fastcgi_script_name; # same path as
above
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
}
--
Posted via http://www.ruby-forum.com/.
More information about the nginx
mailing list