Missing slash on URL?

There is something wrong, when I try to access this location, for
example:

http://localhost/forum

Normally, if I access the above URL, it will automatically add at the
end a
slash:

http://localhost/forum/

The page displays OK. How would I automatically add a / at the end of
each
URL, only if it misses and an actual file is not called from URL? For
example:

http://localhost/forum will turn into http://localhost/forum/ while
http://localhost/forum/test.php remains unchanged.

localhost.conf


server {

  listen                        80;

  server_name                   localhost;

  #charset                      koi-utf;

  access_log                    /var/log/nginx/localhost.access.log

main;

  location / {

        root                    /var/www/html;

        index                   index.php index.html;



        if (-f $request_filename) {

              break;

        }



        if (!-e $request_filename) {

              rewrite ^.*$ /404.html last;

        }

  }



  error_page                    404 /404.html;

  location = /404.html {

        root                    /var/www/html;

  }



  error_page                    500 502 503 504 /50x.html;

  location = /50x.html {

        root                    /var/www/html;

  }



  location ~ \.php$ {

        fastcgi_index           index.php;

        fastcgi_pass            127.0.0.1:9000;

        fastcgi_param           SCRIPT_FILENAME

/var/www/html$fastcgi_script_name;

        include                 /etc/nginx/fastcgi.conf;

  }

}

Thanks for your advice.

On Sun, May 25, 2008 at 3:43 AM, Floren M. [email protected] wrote:

http://localhost/forum/

if (-f $request_filename/index.html) {
rewrite (.*) $1/index.html break;
}

put that in appropriately, and add an “or” if you want to for index.php
as
well…

-jf


In the meantime, here is your PSA:
“It’s so hard to write a graphics driver that open-sourcing it would not
help.”
– Andrew Fear, Software Product Manager, NVIDIA Corporation

On Sat, May 24, 2008 at 03:43:17PM -0400, Floren M. wrote:

  #charset                      koi-utf;
        index                   index.php index.html;

  error_page                    404 /404.html;

        fastcgi_index           index.php;

}
First, instead of

         if (-f $request_filename) {
               break;
         }

         if (!-e $request_filename) {
               rewrite ^.*$ /404.html last;
         }

it’s better to use:

         error_page  404  =/404.html;

Do
/var/www/html/forum
and
/var/www/html/forum/index.php

exist ?

On Sun, May 25, 2008 at 03:32:41PM -0400, Floren M. wrote:

               break;

Thanks Igor, I will do that.

Sorry, I had mistyped:

  •          error_page  404  =/404.html;
    
  •          error_page  404  = /404.html;
    

/var/www/html/forum/index.php exist and is readable, can be accessed through
a browser.

Then /forum will be handled in location ‘/’ as static file or dir,
and it will be redirected to /forum/.

Hi Igor,

a browser.

Then /forum will be handled in location ‘/’ as static file or dir,
and it will be redirected to /forum/.

So how would I make the server add the / at the end of the URL?
If the URL is http://domain.com/forum, I would like it to become
http://domain.com/forum/.

Wordpress uses nginx, as server. If you visit:

the missing slash will be automatically added at the end, to become:

Thanks for your help,

Floren

               break;
         }

         if (!-e $request_filename) {
               rewrite ^.*$ /404.html last;
         }

it’s better to use:

         error_page  404  =/404.html;

Thanks Igor, I will do that.

Do
/var/www/html/forum
and
/var/www/html/forum/index.php

exist ?

/var/www/html/forum is a directory, not a file.
/var/www/html/forum/index.php exist and is readable, can be accessed
through
a browser.

Thanks for clearing this.

On Thu, May 29, 2008 at 12:40 PM, Floren M. [email protected]
wrote:

Then /forum will be handled in location ‘/’ as static file or dir,
and it will be redirected to /forum/.

So how would I make the server add the / at the end of the URL?
If the URL is http://domain.com/forum, I would like it to become
http://domain.com/forum/.

nginx does this already. You dont need to do anything special.

-jf


In the meantime, here is your PSA:
“It’s so hard to write a graphics driver that open-sourcing it would not
help.”
– Andrew Fear, Software Product Manager, NVIDIA Corporation

Hi Jeff,

From: Jeffrey ‘jf’ Lim
[mailto:[email protected]]
Posted At: Thursday, May 29, 2008 1:45 AM
Posted To: gmane.comp.web.nginx.english
Conversation: Missing slash on URL?
Subject: Re: Missing slash on URL?

nginx does this already. You dont need to do anything special.

Hmm, you are right. It was a bad setting I entered, related to
server_name.
server_name localhost;

I was accessing it from 192.168.1.3

Thanks for confirming, it is fixed the issue.