Title: permalink problem on nginx
Last modified: August 20, 2016

---

# permalink problem on nginx

 *  Resolved [ShinichiN](https://wordpress.org/support/users/shinichin/)
 * (@shinichin)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/)
 * I read [Codex > Nginx](http://codex.wordpress.org/Nginx) and succeeded to have
   network install (subdirectory).
 * But I have two problems with permalink settings ( [http://example.com/wp-admin/options-permalink.php](http://example.com/wp-admin/options-permalink.php)).
 * First, I see a slug `/blog` **before** input area.
    Second, there is a slug `/
   index.php/` in the input area.
 * Please see [screenshot](http://nskw-style.com/wordpress/wp-content/uploads/2011/08/link-blog.png).
 * I can’t get rid of either of them.
    (`/blog` is uneditable, and `/index.php/`
   appears every time even I submit without `/index.php/`…:( )
 * I have these problems only at the main (blog id = 1) site.
 * Please if you know how to fix it, please let me know.
 * Here is my nginx config files.
 * nginx.conf:
 *     ```
       user              nginx;
       worker_processes  2;
       error_log  /var/log/nginx/error.log;
       pid        /var/run/nginx.pid;
   
       events {
           worker_connections  1024;
       }
   
       http {
       	include	/etc/nginx/mime.types;
       	default_type 	application/octet-stream;
       	access_log	/var/log/nginx/access.log;
       	sendfile        on;
       	#tcp_nopush     on;
       	keepalive_timeout  3;
       	#tcp_nodelay	on;
       	gzip  on;
       	#client_max_body_size 13m;
       	index      index.php index.html index.htm;
       	log_not_found off;
   
       #	Upstream to abstract backend connection(s) for PHP.
       #	upstream php {
       #		server unix:/tmp/php-fpm.sock;
       #		server 127.0.0.1:9000;
       #	}
   
       	include		sites-enabled/*;
   
       	server {
       	listen       80;
       	server_name  example.com;
       	root /var/www/vhosts/example.com;
   
       	if ($http_host != "example.com") {
       		rewrite ^ http://example.com$request_uri permanent;
       	}
   
       	include global/restrictions.conf;
       	include global/wordpress-ms-subdir.conf;
       	access_log /var/log/nginx/colog.jp.access.log;
   
       	}# end server{}
   
       }# end http {}
       ```
   
 * global/wordpress-ms-subdir.conf:
 *     ```
       # This order might seem weird - this is attempted to match last if rules below fail.
       # http://wiki.nginx.org/HttpCoreModule
       location / {
       	try_files $uri $uri/ /index.php?$args;
       }
   
       # http://j.mp/ni5J6W
       ##necessary if using a multi-site plugin
       server_name_in_redirect off;
       ##necessary if running Nginx behind a reverse-proxy
       #port_in_redirect off;
   
       # Add trailing slash to */wp-admin requests.
       rewrite /wp-admin$ $scheme://$host$uri/ permanent;
   
       # Directives to send expires headers and turn off 404 error logging.
       location ~ .*\.(txt|xml|html?|jpe?g|JPE?G|gif|GIF|png|PNG|swf|SWF|wmv|WMV|flv|FLV|css|CSS|js|JS|inc|ico|gz) {
       	expires 24h;
       	log_not_found off;
       	break;
       }
   
       # Pass uploaded files to wp-includes/ms-files.php.
       rewrite /files/$ /index.php last;
   
       # For multisite:  Use a caching plugin that creates symlinks to the correct subdirectory structure to get some performance gains.
       set $cachetest "$document_root/wp-content/cache/ms-filemap/${host}${uri}";
       if ($uri ~ /$) {
       	set $cachetest "";
       }
       if (-f $cachetest) {
       	# Rewrites the URI and stops rewrite processing so it doesn't start over and attempt to pass it to the next rule.
       	rewrite ^ /wp-content/cache/ms-filemap/${host}${uri} break;
       }
   
       if ($uri !~ wp-content/plugins) {
       	rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last;
       }
   
       # Uncomment one of the lines below for the appropriate caching plugin (if used).
       #include global/wordpress-ms-subdir-wp-super-cache.conf;
       #include global/wordpress-ms-subdir-w3-total-cache.conf;
   
       # Rewrite multisite '.../wp-.*' and '.../*.php'.
       if (!-e $request_filename) {
       	rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
       	rewrite ^/[_0-9a-zA-Z-]+.*(/wp-admin/.*\.php)$ $1 last;
       	rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
       	rewrite ^.*$ /index.php last;
       }
       # Pass all .php files onto a php-fpm/php-fcgi server.
       location ~ \.php$ {
       	root 			html;
       	fastcgi_pass	127.0.0.1:9000;
       	fastcgi_index	index.php;
       	fastcgi_param	SCRIPT_FILENAME /var/www/vhosts/colog.jp$fastcgi_script_name;
       	include			fastcgi_params;
       }
       ```
   
 * Thanks.

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/permalink-problem-on-nginx/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/permalink-problem-on-nginx/page/2/?output_format=md)

 *  Thread Starter [ShinichiN](https://wordpress.org/support/users/shinichin/)
 * (@shinichin)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251722)
 * I reinstalled now subdomain with same code I wrote.
 * And it worked very well.
 * I didn’t get any /blog/ slug before input area or /index.php/ slug in ther input
   area..
 * Is there anyone who has the same problem with me??
 * Thanks..
 *  Thread Starter [ShinichiN](https://wordpress.org/support/users/shinichin/)
 * (@shinichin)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251738)
 * I still don’t know how to fix it…
 * Here are the wrong urls and how I want to fix.
 * Wrong sample page url:
    `http://example.com/index.php/sample-page` I want: `http://
   example.com/sample-page`
 * Wrong category page url:
    `http://example.com/index.php/category/uncategorized`
   It should be: `http://example.com/category/uncategorized`
 * Wrong first post page url:
    `http://example.com/index.php/2011/08/21/1` It should
   be: `http://example.com/2011/08/21/1`
 * The front page is displayed as `http://example.com/` which is ok.
 * I can’t get rid of `index.php/` at “Permalink Setting” page. index.php/ appears
   always even I submit without this slug…
 *  Thread Starter [ShinichiN](https://wordpress.org/support/users/shinichin/)
 * (@shinichin)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251758)
 * I fixed it.
    … not really but almost..
 * I don’t get any /blog slug any more.
 * I still get /index.php slug but I do as follows
 * 1. Define my permalink customize when it’s single install.
 * 2. Never touch permalink submit after multi-sited.
 * 3. You can change permalink structure if you define( ‘MULTISITE’, false );.
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [14 years, 9 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251759)
 * > First, I see a slug /blog before input area.
 * Rolling back to that… I was avoiding this thread b/c I don’t know nginx well,
   but I DO know WordPress, and the blog slug is hard coded in if you’re using subfolder
   installs. You shouldn’t change that.
 *  Thread Starter [ShinichiN](https://wordpress.org/support/users/shinichin/)
 * (@shinichin)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251764)
 * Thank you for the reply!
    I’m glad to know someone cared about my thread 🙂
 * Now I don’t have the /blog slug.
    I customize my permalink as single-installed
   wp user, which is realized by changin define( ‘MULTISITE’, false ); at wp-config.
   php, and then come back to multi-sited wp.
 * Is this going to cause any trouble to my site?
 * I guess /blog slug is required to distinguish the main site from other child 
   blogs..
    Is it something about performance?
 * The main site doesn’t have /blog slug when it’s multi-sited.
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [14 years, 9 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251766)
 * > I guess /blog slug is required to distinguish the main site from other child
   > blogs..
   >  Is it something about performance?
 * Yes and yes. The main site will have /blog slug ONLY if you’re using subfolders(
   subdomains don’t have it).
 *  Thread Starter [ShinichiN](https://wordpress.org/support/users/shinichin/)
 * (@shinichin)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251771)
 * Thank you Ipstenu!
 * Is there any problem to leave the setting as it is?
    I mean that I don’t insert/
   blog slug (it’s possible to set permalink setting as single wp user and then 
   get multi-sited).
 * If it is possible to cause a serious trouble, can I change /blog to something
   else like /home or /main?
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [14 years, 9 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251772)
 * It can cause problems with any blogs named ‘blog’, but if you make sure not to
   do THAT, you’re okay.
 * You can’t (currently) rename it. it’s actually hard coded into the permalink 
   page. If you save permalinks, it SHOULD force it back it (it does on .htaccess/
   apache sites, dunno if nginx makes it different).
 *  Thread Starter [ShinichiN](https://wordpress.org/support/users/shinichin/)
 * (@shinichin)
 * [14 years, 9 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251773)
 * Thanks!
 * I guess /blog slug is not able to be used as new child blog slug for it’s listed
   as unavailable in the network setting page.
    And maybe I shouldn’t /blog as category/
   tag slugs..:|
 * And ofcourse I’ll avoid clicking submit button at permalink setting page:)
 * Thanks, Ipstenu!
    Now my questions are all resolved! I hope this thread will 
   be good for the wp community too!
 *  [mikeatkc](https://wordpress.org/support/users/mikeatkc/)
 * (@mikeatkc)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251904)
 * How did you fixed the issue? I saw you post your config and then it doesn’t work
   and then it worked. What did you do? I’m running nginx 0.8.54 and WP 3.2.1 (not
   multisite). If I changed the PERMALINKS from “Default” to “Day and name” all 
   my links are broken and so does some plugins.
 * Is it as simple as having the rewrite rule below in nginx.conf?
 *     ```
       if ($http_host != "example.com") {
       		rewrite ^ http://example.com$request_uri permanent;
       ```
   
 *  [mikeatkc](https://wordpress.org/support/users/mikeatkc/)
 * (@mikeatkc)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251905)
 * Discovered another post, the below links help:
 *     ```
       http://wordpress.org/support/topic/working-nginx-rewrite-rules-for-wordpress-multisite-3x-wp-super-cache?replies=12
   
       http://wiki.nginx.org/Wordpress
       ```
   
 *  Thread Starter [ShinichiN](https://wordpress.org/support/users/shinichin/)
 * (@shinichin)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251907)
 * I found a plugin to remove /blog.
 * [http://www.thinkinginwordpress.com/?s=Remove+%2Fblog+slug+plugin+for+wpmu](http://www.thinkinginwordpress.com/?s=Remove+%2Fblog+slug+plugin+for+wpmu)
 *  Moderator [Ipstenu (Mika Epstein)](https://wordpress.org/support/users/ipstenu/)
 * (@ipstenu)
 * 🏳️‍🌈 Advisor and Activist
 * [14 years, 6 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251908)
 * That plugin doesn’t work with 3.2 last I checked.
 *  [Justin Frydman](https://wordpress.org/support/users/defunctlife/)
 * (@defunctlife)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251912)
 * Add this to functions.php
 * `add_filter( 'got_rewrite', '__return_true', 999 );`
 * WordPress is checking if mod_rewrite is enabled (which of course it’s not since
   we aren’t using Apache), so force this to return true and it won’t add the additional
   index.php into the permalinks.
 * Then, just save your permalinks again and you should be good to go.
 *  [treccase](https://wordpress.org/support/users/treccase/)
 * (@treccase)
 * [14 years, 5 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/#post-2251915)
 * Hi,
 * Use [Nginx Compatibility by Vladimir Kolesnikov](http://wordpress.org/extend/plugins/nginx-compatibility/)
   to setup your permalinks running on nginx (it does basically the same thing as
   defunctlife wrote above + more)

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/permalink-problem-on-nginx/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/permalink-problem-on-nginx/page/2/?output_format=md)

The topic ‘permalink problem on nginx’ is closed to new replies.

## Tags

 * [nginx](https://wordpress.org/support/topic-tag/nginx/)
 * [permalink](https://wordpress.org/support/topic-tag/permalink/)

 * In: [Networking WordPress](https://wordpress.org/support/forum/multisite/)
 * 16 replies
 * 6 participants
 * Last reply from: [harrymfa](https://wordpress.org/support/users/harrymfa/)
 * Last activity: [13 years, 10 months ago](https://wordpress.org/support/topic/permalink-problem-on-nginx/page/2/#post-2251949)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
