Laravel Nginx下配置路由 404 重定向 去index.php的rewrite的规则
2014-11-30 15:30
465 查看
server里加入:
配置文件如下:
或者:
# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename)
{
rewrite ^/(.+)/$ /$1 permanent;
}
# removes trailing "index" from all controllers
if ($request_uri ~* index/?$)
{
rewrite ^/(.*)/index/?$ /$1 permanent;
}
# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
location / { try_files $uri $uri/ /index.php$is_args$query_string; }
配置文件如下:
server
{
listen 80;
#listen [::]:80;
server_name www.xxxxx.com xxxxx.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/www.pjcms.com/public;
include other.conf;
#error_page 404 /404.html;
location / { try_files $uri $uri/ /index.php$is_args$query_string; }
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log /home/wwwlogs/www.pjcms.com.log access;
}
或者:
# removes trailing slashes (prevents SEO duplicate content issues)
if (!-d $request_filename)
{
rewrite ^/(.+)/$ /$1 permanent;
}
# removes trailing "index" from all controllers
if ($request_uri ~* index/?$)
{
rewrite ^/(.*)/index/?$ /$1 permanent;
}
# unless the request is for a valid file (image, js, css, etc.), send to bootstrap
if (!-e $request_filename)
{
rewrite ^/(.*)$ /index.php?/$1 last;
break;
}
相关文章推荐
- ThinkPHP5 Nginx下的配置——支持pathinfo访问和隐藏入口文件index.php的rewrite规则
- apache配置rewrite规则,删除url中的index.php
- Nginx配置REWRITE隐藏index.php
- Nginx配置PHP的Yii与CakePHP框架的rewrite规则示例
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- php 开启伪静态 配置路由规则
- nginx rewrite 规则:codeigniter在nginx下配置详解(去除index.php)
- 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- NGINX配置PHPINFO文件解决Dilicms后台无法index.php出现404
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- CI框架在 nginx 服务器上配置 rewrite 去掉 index.php 的方法:
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- ThinkPHP 利用.htaccess文件的 Rewrite 规则隐藏URL中的 index.php
- nginx配置后只有根目录首页index.php能访问,其他页面404
- apache 配置rewrite模块,URL中隐藏index.php