LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
Search this Thread
Old 09-14-2010, 05:12 AM   #1
Coburn64
LQ Newbie
 
Registered: Jul 2009
Location: Australia
Distribution: Debian GNU/Linux 6.0 Squeeze
Posts: 27

Rep: Reputation: 16
Question Nginx Virtual Hosts & Wordpress Rewrite Rules


Hi,

I'm trying to set up my web server (nginx) as a catchall virtual host, as per an example that can be seen here: http://wiki.nginx.org/NginxVirtualHostExample (It's the Wildcard Subdomains in a Parent Folder example).

Now, here's my issue. I use Wordpress on the coburndomain.org domain. I have pretty URLs enabled, that make my Wordpress articles look like this:

somesite_DOT_com/index.php/2010/09/woo-hoo-this-works-2/

At the moment, nginx is reporting 500 Errors, saying that index.php is not a directory. What I want to do is make a rewrite rule that allows me to use the above URL example with nginx.

I followed this tutorial to do so: http://www.romej.com/archives/515/ng...ordpress-redux , but I'm not sure how to apply it to my setup. Here's my configuration files from Debian Squeeze with Nginx onboard:

/etc/nginx/nginx.conf

Code:
user www-data;
worker_processes  1;

error_log  /private/www/logs/error.log;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
    # multi_accept on;
}

http {
    include       /etc/nginx/mime.types;

    access_log  /private/www/logs/access.log;
    log_format main '$remote_addr $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    tcp_nodelay        on;

    gzip  on;
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}
/etc/nginx/sites-enabled/vhosts

Code:
server {
  # Replace this port with the right one for your requirements
  listen       80;  #could also be 1.2.3.4:80

  # Multiple hostnames separated by spaces.  Replace these as well.
  server_name  iceprism.coburndomain.org ;

  root /private/www/vhosts/$host;

  # error_page  404 ;
  access_log  /private/www/logs/access.log;

  index  index.php index.html index.htm;

  # serve static files directly
  location ~* ^.+\.(jpg|jpeg|gif|css|png|js|ico|html)$ {
    access_log        off;
    expires           30d;
  }

# Dunno what this does...
#       location / {
#        try_files $uri $uri/ /index.php$uri =404;
#}
# This didn't work either >_>
#   if (!-e $request_filename) {
#            rewrite ^/(.*)$  /index.php/$1 last;
#   }

  location ~ .php$ {
    # By all means use a different server for the fcgi processes if you need to
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
      fastcgi_param  REQUEST_URI      $request_uri;
      fastcgi_param  DOCUMENT_URI     $document_uri;
      fastcgi_param  DOCUMENT_ROOT    $document_root;
      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;
      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_intercept_errors on;
  }

  location ~ /\.ht {
    deny  all;
  }
}
Could anyone shine some light onto this? Nginx is by far the best webserver for my needs, and I hate to have to turn off SEO-friendly Wordpress URLs.

Cheers,
Coburn64
 
Old 09-15-2010, 01:58 PM   #2
Web31337
Member
 
Registered: Sep 2009
Location: Russia
Distribution: Gentoo, LFS
Posts: 399
Blog Entries: 71

Rep: Reputation: 65
Code:
if ( !-e $request_filename) {
    rewrite ^.* /index.php last;
}
and remove that ugly "index.php/" from wordpress URI scheme.

Last edited by Web31337; 09-15-2010 at 02:03 PM.
 
  


Reply

Tags
nginx, rewrite, url


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
wordpress on nginx sandeepthug Linux - Software 1 07-23-2010 11:54 AM
[SOLVED] how to config NGINX for multiple domains with wordpress on Debian? karelkap Linux - Server 1 06-21-2010 11:21 AM
nginx 0.7.65 rewrite url with querystring problem? gavin2u Linux - Server 0 04-07-2010 07:46 PM
Apache rewrite for Virtual Hosts deploy_update Linux - Server 3 08-14-2009 02:51 AM
Apache virtual host, rewrite & proxy question NickDeGraeve Linux - Server 8 02-02-2009 07:09 PM


All times are GMT -5. The time now is 12:27 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration