Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Server
User Name
Linux - Server This forum is for the discussion of Linux Software used in a server related context.


  Search this Thread
Old 09-14-2010, 06:12 AM   #1
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


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

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


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: , but I'm not sure how to apply it to my setup. Here's my configuration files from Debian Squeeze with Nginx onboard:


user www-data;
worker_processes  1;

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

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/*;

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

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

  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_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.

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

Rep: Reputation: 65
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 03:03 PM.


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 12:54 PM
[SOLVED] how to config NGINX for multiple domains with wordpress on Debian? karelkap Linux - Server 1 06-21-2010 12:21 PM
nginx 0.7.65 rewrite url with querystring problem? gavin2u Linux - Server 0 04-07-2010 08:46 PM
Apache rewrite for Virtual Hosts deploy_update Linux - Server 3 08-14-2009 03:51 AM
Apache virtual host, rewrite & proxy question NickDeGraeve Linux - Server 8 02-02-2009 08:09 PM > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 06:03 PM.

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