我正在使用 yii 框架开发一个 CMS。有前端和后端。我希望用户能够像这样访问后端:http ://www.mysite.com/admin ,现在它的工作方式是这样的:http ://www.mysite.com/admin.php 。
对于后端,我已经定义了不同的部分,它有自己的配置、控制器和......以及用于访问 admin.php 中的后端的页面
这是我的目录结构:
...
admin
--components
--config
---main.php
--controllers
---NewsController.php
---ShowCOntroller.php
---SiteController.php
--models
---LoginForm.php
---News.php
---Show.php
---User.php
--runtime
...
--Views
---layouts
---news
---show
---site
protected
-commands
-data
-extentions
-messages
-migrations
-models
-modules
--image
-runtime
-views
themes
uploads
admin.php
index.php
.htaccess
这是我的 .htaccess 文件:
Options +FollowSymLinks
IndexIgnore */*
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule admin admin\.php [T=application/x-httpd-php]
# if a directory or a file exists, use it directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward it to index.php
RewriteRule . index.php
</IfModule>