脚本宝典收集整理的这篇文章主要介绍了Apache 透过 htaccess 隐藏 php 副档名(mod_rewrite),脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
本教学使用环境介绍
伺服器端:Ubuntu 18.04 LTS
资料库:Mariadb 10.1.34(Mysql)
语言版本:php 7.3
本机端:MacOS High Sierra
首先安装好 apache 后,启用 rewrite 功能
$ a2enmod rewrite
然后再到 /etc/apache2/apache2.conf
添加内容
$ nano /etc/apache2/apache2.conf
内容为
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
记得将路径设为你的网站根目录路径呦!
接着将 apache reload
service apache2 reload
然后去你的网站根目录中添加档案为 .htaccess,并加入以下内容
Options -Indexes
Options +FollowSymlinks
RewriteEngine on
在同一个 .htaccess
档案中添加 RewriteRule,就像这样
Options -Indexes
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^admin/index$ admin/index.php
这样只要访问路径 /admin/index
就等于是访问了 /admin/index.php
,apache已经帮你隐藏副档名了
Line ID:ianmac
QQ:1258554508
以上是脚本宝典为你收集整理的Apache 透过 htaccess 隐藏 php 副档名(mod_rewrite)全部内容,希望文章能够帮你解决Apache 透过 htaccess 隐藏 php 副档名(mod_rewrite)所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。