Skip to content

Instantly share code, notes, and snippets.

@carrot
Created March 15, 2010 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carrot/333193 to your computer and use it in GitHub Desktop.
Save carrot/333193 to your computer and use it in GitHub Desktop.
I am trying to switch from apache to nginx. for my wordpress and vanillaforums setup.
Essentially I need the wordpress rewrite to work correctly with vanilla forums
rewrite.
I have gist'd the apache rewrite I'm trying to emulate and
my current nginx config.
####################################################
# This lived in an .htaccess file at {ROOT}/forums
####################################################
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>
upstream myphp {
server 127.0.0.1:53217;
}
server {
listen 80;
server_name www.example.com;
rewrite ^/(.*) http://example.com/$1 permanent;
}
server {
listen 80;
server_name example.com;
access_log /home/deploy/public_html/example.com/shared/log/access.log;
error_log /home/deploy/public_html/example.com/shared/log/error.log;
location / {
root /home/deploy/public_html/example.com/current/public/;
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~\.php$ {
fastcgi_pass myphp;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/deploy/public_html/example.com/current/public/$fastcgi_script_name; # same pa$
fastcgi_param HOME_ROOT /home/deploy/public_html/example.com/current/public/forums;
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;
}
####################################
# AN ASSORTMENT OF THINGS I'VE TRIED
####################################
#location /forums/ {
# try_files $uri $uri/ /forums/index.php?q=$uri&$args;
# try_files $uri $uri/ @forums;
#}
#location @forums {
# include fastcgi_params;
# fastcgi_param SCRIPT_FILENAME $document_root/forums/index.php;
# fastcgi_param QUERY_STRING q=$uri&$args;
# fastcgi_pass my_php;
#}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment