# Drupal clean urls

**URL:** <https://www.ruby-forum.com/t/drupal-clean-urls/236500>\
**Category:** NGINX\
**Created:** [September 8, 2013, 8:44pm UTC](https://www.ruby-forum.com/t/drupal-clean-urls/236500 "2013-09-08T20:44:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alcina](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@alcina](https://www.ruby-forum.com/u/alcina)\
**Post date:** [September 8, 2013, 8:44pm UTC](https://www.ruby-forum.com/t/drupal-clean-urls/236500/1 "2013-09-08T20:44:56Z")

</div>

Greetings

I have followed all the instructions in the wiki, and when i set my  
drupal  
installations as the root, everything works, however, when i move my  
drupal  
into a folder i am able to get everything to work except clean urls.

Here is my drupal config:  
location /blog {  
# This is cool because no php is touched for static  
content  
try\_files $uri @rewrite;  
}

```
    location @rewrite {
            # You have 2 options here
            # For D7 and above:
            # Clean URLs are handled in

```

drupal\_environment\_initialize().  
#rewrite ^ /blog/index.php;  
# For Drupal 6 and bwlow:  
# Some modules enforce no slash (/) at the end of the  
URL  
# Else this rewrite block wouldn’t be needed  
(GlobalRedirect)  
rewrite ^blog/(.\*)$ blog/index.php?q=$1;  
}

```
    location ~ blog/.*\.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            #NOTE: You should have "cgi.fix_pathinfo = 0;" in 

```

php.ini  
include fastcgi\_params;  
fastcgi\_param SCRIPT\_FILENAME $request\_filename;  
fastcgi\_intercept\_errors on;  
fastcgi\_pass unix:/var/run/php-fpm/php-fpm.sock;  
}

```
    # Fighting with Styles? This little gem is amazing.
    # This is for D6
    #location ~ ^/sites/.*/files/imagecache/ {
    # This is for D7 and D8
    location ~ ^/blog/sites/.*/files/styles/ {
            try_files $uri @rewrite;
    }

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
            expires max;
            log_not_found off;
    }

```

Here is the error i am seeing in my log:  
[error] 12988#0: \*1 open() “/var/www/html/blog/linux” failed (2: No such  
file or directory), client: 192.168.1.1, server: localhost, request:  
“GET  
/blog/linux HTTP/1.1”, host: “[example.com](http://example.com)”, referrer:  
“[http://example.com/blog/](http://example.com/blog/)”

(names have been changed to protect the innocent 😉

any help is appreciated.

thanks!  
Adam

Posted at Nginx Forum:

> **[drupal clean urls](https://forum.nginx.org/read.php?2,242673,242673#msg-242673)**
>
> Greetings I have followed all the instructions in the wiki, and when i set my drupal installations as the root, everything works, however, when i move my drupal into a folder i am able to get everything to work except clean urls. Here is my drupal...

---

<div class="post-metadata">

**Author:** ![adambot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7feea3/32.png) [@adambot](https://www.ruby-forum.com/u/adambot)\
**Post date:** [September 8, 2013, 11:10pm UTC](https://www.ruby-forum.com/t/drupal-clean-urls/236500/2 "2013-09-08T23:10:57Z")

</div>

On Sun, Sep 08, 2013 at 02:44:08PM -0400, adambot wrote:

Hi there,

not tested, and I don’t know what exactly drupal expects, but…

> ```
> location @rewrite {
> 
> ```

> ```
> rewrite ^blog/(.*)$ blog/index.php?q=$1;
> 
> ```

That “rewrite” line is unlikely to do anything. The uri that “rewrite”  
tests starts with a /, so “^blog” will never match.

Perhaps replace “blog” with “/blog” twice, and see if that does what  
you want?

Separate from that, and this is more “busy work” than “actually  
broken”…

> ```
> location ~ blog/.*\.php$ {
> fastcgi_split_path_info ^(.+\.php)(/.+)$;
> 
> ```

That line probably does nothing useful. There aren’t many urls that  
both end in “.php” and contain the string “.php/”. Something like  
/blog/one.php/two.php _would_ match – but does your drupal use urls  
like that?

> Here is the error i am seeing in my log:  
> [error] 12988#0: \*1 open() “/var/www/html/blog/linux” failed (2: No such  
> file or directory), client: 192.168.1.1, server: localhost, request: “GET  
> /blog/linux HTTP/1.1”, host: “[example.com](http://example.com)”, referrer:  
> “[http://example.com/blog/](http://example.com/blog/)”

I suspect that if you turned on the debug log, you’d see what rewrites  
were actually used; and you could match that against what you expect  
nginx to do.

But the blog → /blog change may be enough to get things going.

## f

Francis D. removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![adambot](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/7feea3/32.png) [@adambot](https://www.ruby-forum.com/u/adambot)\
**Post date:** [September 9, 2013, 7:25am UTC](https://www.ruby-forum.com/t/drupal-clean-urls/236500/3 "2013-09-09T07:25:24Z")

</div>

Changing the rewrite from blog to /blog worked perfectly – thanks for  
the  
second set of eyes 🙂

I’m not sure on the busy-work part – i took most of the stuff from the  
nginx wiki on drupal (still learning config files, been running nginx  
for  
about 24 hours now)

Posted at Nginx Forum:

> **[Re: drupal clean urls](https://forum.nginx.org/read.php?2,242673,242677#msg-242677)**
>
> Greetings I have followed all the instructions in the wiki, and when i set my drupal installations as the root, everything works, however, when i move my drupal into a folder i am able to get everything to work except clean urls. Here is my drupal...
