ngnix服务器,进入:nginx/conf/vhosts.conf:
server { listen 80; server_name www.x.com x.com; root "C:\Runing\PHPTutorial"; location / { index index.html index.htm index.php; #autoindex on; } /** 添加的代码 *****/ if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?/$1 last; break; } /** 添加的代码 *****/ location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.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; include fastcgi_params; } }
apache服务器根目录添加 (.htaccess)文件,添加内容如下:
<IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L] </IfModule>
apache服务器根目录添加(.htaccess)文件,使laravel 的 public 为网站入口,其它框架类似。
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule ^(.*)$ index.php/$1 [L] RewriteRule ^(.*)$ /public/$1 RewriteRule ^(/)?$ public/index.php [L]