when nginx configures laravel routing, it is found that "domain name / index" can be accessed normally, but if you use the domain name / / index, it will be automatically redirected to /
.nginx.conf
-sharpuser nobody;
worker_processes 1;
-sharperror_log logs/error.log;
-sharperror_log logs/error.log notice;
-sharperror_log logs/error.log info;
-sharppid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
include F:/Server/nginx/conf/vhost.conf;
default_type application/octet-stream;
-sharplog_format main "$remote_addr - $remote_user [$time_local] "$request" "
-sharp "$status $body_bytes_sent "$http_referer" "
-sharp ""$http_user_agent" "$http_x_forwarded_for"";
-sharpaccess_log logs/access.log main;
sendfile on;
-sharptcp_nopush on;
-sharpkeepalive_timeout 0;
keepalive_timeout 65;
-sharpgzip on;
server {
listen 80;
server_name localhost;
-sharpcharset koi8-r;
-sharpaccess_log logs/host.access.log main;
location / {
root F:/Server/WebSites;
index index.php index.html index.htm;
}
-sharperror_page 404 /404.html;
-sharp redirect server error pages to the static page /50x.html
-sharp
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
-sharp proxy the PHP scripts to Apache listening on 127.0.0.1:80
-sharp
-sharplocation ~ \.php$ {
-sharp proxy_pass http://127.0.0.1;
-sharp}
-sharp pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
-sharp
location ~ \.php$ {
root F:/Server/WebSites;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
-sharp deny access to .htaccess files, if Apache"s document root
-sharp concurs with nginx"s one
-sharp
-sharplocation ~ /\.ht {
-sharp deny all;
-sharp}
}
-sharp another virtual host using mix of IP-, name-, and port-based configuration
-sharp
-sharpserver {
-sharp listen 8000;
-sharp listen somename:8080;
-sharp server_name somename alias another.alias;
-sharp location / {
-sharp root html;
-sharp index index.html index.htm;
-sharp }
-sharp}
-sharp HTTPS server
-sharp
-sharpserver {
-sharp listen 443 ssl;
-sharp server_name localhost;
-sharp ssl_certificate cert.pem;
-sharp ssl_certificate_key cert.key;
-sharp ssl_session_cache shared:SSL:1m;
-sharp ssl_session_timeout 5m;
-sharp ssl_ciphers HIGH:!aNULL:!MD5;
-sharp ssl_prefer_server_ciphers on;
-sharp location / {
-sharp root html;
-sharp index index.html index.htm;
-sharp }
-sharp}
}
vhost.conf
server {
listen 80;
server_name local.kalvin.com;
root F:/Server/WebSites/kalvinBlog/public;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ @rewrite;
}
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
if (!-d $request_filename)
{
rewrite ^/(.+)/$ /$1 permanent;
}
if ($request_uri ~* index/?$)
{
rewrite ^/(.*)/index/?$ /$1 permanent;
}
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
}
laravel routing:
accessing / * * / any file name will not be redirected, except index