How to remove extension with mor rewrite
Igor Sysoev
is at rambler-co.ru
Fri Nov 2 22:33:34 MSK 2007
On Sat, Nov 03, 2007 at 01:40:18AM +0700, Ninh Nguyen wrote:
> How to auto add .php after filename with this kind of url: download?a=x&b=y&....
> and auto add index.php if we type www.domain.com/ or domain.com/
> I tried but it does not work
>
> if (-f $request_filename/index.php) {
> rewrite (.*) $1/index.php break;
> }
> if (-f $request_filename.php) {
> rewrite (.*) $1.php break;
> }
Try the following:
server {
location = / {
rewrite ^ /index.php last;
}
location / {
if ($request_filename.php) {
rewrite (.*) $1.php last;
}
root ...;
...
}
location ~ \.php$ {
proxy_pass or fastcgi_pass ...
...
}
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list