1.打開front.hyii2.com,點擊右側(cè)的About標(biāo)簽,可以看到域名中有index.php

Paste_Image.png
2.在hyii2文件夾下找到frontend-->web文件夾,在文件夾中新建“.htaccess”文件

Paste_Image.png
將下面的這幾行配置代碼復(fù)制到“.htaccess”中,保存
RewriteEngine on
# 如果是一個目錄或者文件,就訪問目錄或文件
RewriteCond %{REQUEST_FILENAME} !-d
# 如果文件存在,就直接訪問文件,不進行下面的RewriteRule
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php
3.去掉域名中的index.php,仍然可以訪問。

去掉index
4.打開frontend文件夾下config-->main.php,在return的數(shù)組中,將urlManager的注釋取消,如果沒有則添加urlManager的代碼

Paste_Image.png

Paste_Image.png
完成后,刷新frontend.hyii2.com,點擊右邊的About標(biāo)簽,可以看到域名中路徑和我們平時看到的網(wǎng)站就一樣了,沒有index文件和符號,只有干凈的路徑。

Paste_Image.png
也可以在urlManager中設(shè)置網(wǎng)頁的后綴

Paste_Image.png
可以看到網(wǎng)頁域名有了.html的后綴,其實不加也可以。

Paste_Image.png