现在隐藏掉一个index.php,还有一个入口文件admin.php没办法隐藏,如何做?.htacess文件内容如下
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
现在隐藏掉一个index.php,还有一个入口文件admin.php没办法隐藏,如何做?.htacess文件内容如下
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
题主是想说: 怎么从URL上隐藏index.php或是实现URL 重写功能?
# 确定 apache 开启了 rewrite_mod!
# Set document root to be "basic/web"
DocumentRoot "path/to/basic/web"
<Directory "path/to/basic/web">
# use mod_rewrite for pretty URL support
RewriteEngine on
# If a directory or a file exists, use the request directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Otherwise forward the request to index.php
RewriteRule . index.php
# ...other settings...
</Directory>
摘自 yii2-apache-config: 是Yii 2的资料, 但同理。
有三种解决方案:
目录结构跟你说的一致:类似
htaccess这样写即可。
目录结构
目录结构