apche中网站根目录下创建.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
或者
Options +FollowSymLinks -Indexes
RewriteEngine On
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
在wampserver中:
#
<VirtualHost *:80>
RewriteEngine on
RewriteCond $1 !^(index\.php|\/public)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php/$1 [L]
ServerName www.webnav.site
DocumentRoot "e:/wampserver/www/webnav"
<Directory "e:/wampserver/www/webnav/">
AllowOverride all
Require all granted
</Directory>
</VirtualHost>
nginx中配置文件中(laravel)
location / {
try_files $uri $uri/ /index.php?$query_string;
}
如果你用的是thinkphp ,nginx配置文件中(thinkphp5)
location / {
index index.php index.html index.htm;
if (-e $request_filename) {
break;
}
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ .+\.php($|/) {
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_pass 127.0.0.1:9010;
include fastcgi_params;
}
在thinkphp5中,你用上面那个短的配置文件,就是有问题,路由后面的参数就是不给你当参数解析,在首页给你绕来绕去