Missing slash on URL?
Igor Sysoev
is at rambler-co.ru
Sun May 25 22:40:04 MSD 2008
On Sat, May 24, 2008 at 03:43:17PM -0400, Floren Munteanu wrote:
> 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;
>
> }
>
> }
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 ?
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list