Apache 透过 htaccess 隐藏 php 副档名(mod_rewrite)
文章目录
首先安装好 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已经帮你隐藏副档名了
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论