apache修改
1.加載httpd.conf配置文件中mod_rewrite.so模塊:
打開httpd.conf配置文件,找到以下擴展 , 將其前面的#號去掉 , 重啟apache
LoadModule rewrite_module modules/mod_rewrite.so
2.修改httpd-vhosts.conf配置文件
將AllowOverride None 的None改為 All
3.搜索DocumentRoot 將根目錄設(shè)置成你的入口文件所在目錄
image.png
4.修改.htaccess文件
把下面的內(nèi)容保存為.htaccess文件放到應(yīng)用入口文件的同級目錄下国旷,就在public目錄
<IfModule mod_rewrite.c>
Options +FollowSymlinks -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
</IfModule>
5.重啟Apache服務(wù)器
(如果是其他服務(wù)器匿级,可參閱官方手冊 URL重寫)
Nginx 修改
1.找到對應(yīng)的網(wǎng)站配置文件nginx.conf(一般位于 /etc/nginx/nginx.conf)
2.
location / {
root html/dddai/public/;
index index.php index.html;
#主要是這句
try_files $uri /index.php?$uri;
}
以下寫法為特殊情況, 項目放在prosys文件夾下
location /prosys/ {
index index.html index.htm index.php;
if (!-e $request_filename){
rewrite ^/prosys/(.*)$ /prosys/index.php?s=$1 last;
}
}