我的网址看起来像这样的http:www.example.com/subdirectory。代码存在于此子目录中。我希望我的应用程序运行在http:www.example.com。我在.htaccess文件中尝试了多个重写规则。如何使它工作?
答案 0 :(得分:1)
您可以通过更改config文件夹中的routes.php来实现这一目标
将此添加到routes.php
$route['default_controller'] = "subdirectory/home";
$route['404_override'] = '';
$route['subdirectory'] = "subdirectory/home";
$route['subdirectory/(:any)'] = "subdirectory/$1";
答案 1 :(得分:0)
您可以将此规则放在根.htaccess
(子目录上方的级别)中:
RewriteEngine On
RewriteBase /
RewriteRule ^((?!subdirectory/).*)$ subdirectory/$1 [L,NC]