Home  >  Article  >  Backend Development  >  How to hide index.php in ubuntu

How to hide index.php in ubuntu

藏色散人
藏色散人Original
2020-04-26 13:46:542420browse

How to hide index.php in ubuntu

ubuntu隐藏index.php的方法

ubuntu-apache下隐藏thinkphp入口文件index.php

按照thinkphp手册中来讲,apache服务器下,隐藏thinkphp入口文件有3步:

1.httpd.conf配置文件中加载了mod_rewrite.so模块

2.AllowOverride None 将None改为 All

3.把下面的内容保存为.htaccess文件放到应用入口文件的同级目录下:                                                          

mod_rewrite.c>
RewriteEngine
on
RewriteCond
%{REQUEST_FILENAME}
!-d
RewriteCond
%{REQUEST_FILENAME}
!-f
RewriteRule
^(.*)$
index.php/$1 [QSA,PT,L]

ps:前两项在apache配置文件中

但在实际操作中发现几个问题:

1.在ubuntu下没有httpd.conf配置文件,只有apache2.conf,据说前者是用户自定义配置文件

2.apache2.conf中没有mod_rewrite.so(windows中把配置文件中包含这行的代码注释去掉即可完成配置)

解决办法:

   

a.终端:a2enmod rewrite ,完成后重启服务器

   

b.做启动链接(下次启动自动加载)(我在执行时提醒说已经存在了):

   

ln -s /etc/apache2/mods-available/rewrite.load
/etc/apache2/mods-enabled/rewrite.load

    

重启服务器

更多相关知识,请关注 PHP中文网!!

The above is the detailed content of How to hide index.php in ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn