小编Bra*_*nJW的帖子

使用NginX和Laravel:URL重写

我正在尝试在运行CentOS 6.4和NginX 1.8的VPS上设置Laravel框架.我可以完全正常地工作,除了我无法使用更干净的URL工作,例如使用"website.com/home"而不是"website.com/index.php/home".有人可以帮忙吗?这是我当前虚拟主机配置文件的内容.

server {

    listen 80;
    server_name swati.havok.semicolony.com;
    access_log /usr/share/nginx/semicolony.com/_subdomains/swati/storage/logs/access.log;
    error_log /usr/share/nginx/semicolony.com/_subdomains/swati/storage/logs/errors.log;

    root /usr/share/nginx/semicolony.com/_subdomains/swati/public;
    index index.php;

    #browse folders if no index file
    autoindex on;

    # enforce NO www
    if ($host ~* ^www\.(.*))
    {
        set $host_without_www $1;
        rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
    }

    # serve static files directly
    location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
        access_log off;
        #expires max;
    }

    # removes trailing slashes (prevents SEO duplicate content issues)
    if (!-d $request_filename)
    {
        rewrite ^/(.+)/$ /$1 permanent;
    }

    # removes trailing "index" from all …
Run Code Online (Sandbox Code Playgroud)

nginx url-rewriting laravel

2
推荐指数
1
解决办法
8767
查看次数

标签 统计

laravel ×1

nginx ×1

url-rewriting ×1