现在隐藏掉一个index.php,还有一个入口文件admin.php没办法隐藏,如何做?.htacess文件内容如下
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,PT,L]
有三种解决方案:
-
目录结构跟你说的一致:类似
-admin.php -index.php -Admin -Home
htaccess这样写即可。
Options +FollowSymlinks RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ad(.*)$ admin.php/$1 [L] RewriteRule ^home(.*)$ index.php/$1 [L]
意思就是需要定义index.php和admin.php的目录前缀来区分是调用哪个入口文件。访问index.php就是
$hostname/home//$ctrolller/$action
;访问admin.php 即通过$hostname/home//$ctrolller/$action
. -
目录结构
-Admin -index.php -.htacess -Home -index.php -.htacees -Thinkphp -ThinkPHP.php
这样app组方式的调用公共的Thinkphp库.不需要修改默认的.htaccess。访问Home.即
$hostname/Home/$ctrolller/$action
; -
目录结构
-APP -Admin -Home -Thinkphp -ThinkPHP.php -index.php
这是thinkphp官方推荐的分组模式。thinkphp分组配置。
'APP_GROUP_LIST' => 'Home,Admin', //项目分组设定 'DEFAULT_GROUP' => 'Home', //默认分组
访问Home.$hostname/$ctrolller/$action
;
访问admin$hostname/Admin/$ctrolller/$action
;
改个名字,要不定时任务,改名..发邮件..
题主是想说: 怎么从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的资料, 但同理。