0
之前有人說這是重複的 - 我嘗試了所有其他類似的問題,沒有任何成功的結果。如何使用Apache在我的網站的URL中隱藏文件擴展名?
我使用apache。
我正在試圖隱藏URL中的文件擴展名。例如,index.php會在URL中顯示爲索引。
所以我做了什麼:
1)我創建了一個.htaccess文件,粘貼到這個吧:
Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule^- [NC]
RewriteCond %{REQUEST_URI} ^/(.+?)/$
RewriteCond %{DOCUMENT_ROOT}/%1\.html -f
RewriteRule^/%1.html [L]
RewriteCond %{REQUEST_URI} ^/(.+?)/$
RewriteCond %{DOCUMENT_ROOT}/%1\.php -f
RewriteRule^/%1.php [L]
2)上傳到.htacccess
夾www/html
3)重新啓動的阿帕奇
4)Ran sudo a2enmod rewrite
5)重啓動Apache的再次
6)赴/etc/apache2/sites-enabled/000-default.conf
並在<VirtualHost *:80>
標籤粘貼此:
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
7)重新啓動Apache的
而且......文件擴展名仍然顯示在我的網站。這是我第一次玩弄.htaccess,所以有人可以解釋我做錯了什麼,我應該採取哪些步驟來正確地做到這一點?