teck
May 24, 2008, 9:55pm
1
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.
teck
May 25, 2008, 3:53pm
2
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
Thirty years ago, Linus Torvalds was a 21 year old student at the University of Helsinki when he first released the Linux Kernel. His announcement started, “I’m doing a (free) operating system (just a hobby, won't be big and professional…)”. Three...
teck
May 25, 2008, 8:50pm
3
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 ?
teck
May 27, 2008, 10:46am
4
On Sun, May 25, 2008 at 03:32:41PM -0400, Floren M. wrote:
break;
Thanks Igor, I will do that.
Sorry, I had mistyped:
/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/.
teck
May 29, 2008, 6:52am
5
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
teck
May 26, 2008, 8:13am
6
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.
teck
May 29, 2008, 7:59am
7
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
Thirty years ago, Linus Torvalds was a 21 year old student at the University of Helsinki when he first released the Linux Kernel. His announcement started, “I’m doing a (free) operating system (just a hobby, won't be big and professional…)”. Three...
teck
May 29, 2008, 12:19pm
8
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.