我想使用根目录中的 public class UnityConfig
{
#region Unity Container
private static Lazy<IUnityContainer> container = new Lazy<IUnityContainer>(() =>
{
var container = new UnityContainer();
RegisterTypes(container);
return container;
});
/// <summary>
/// Gets the configured Unity container.
/// </summary>
public static IUnityContainer GetConfiguredContainer()
{
return container.Value;
}
#endregion
/// <summary>Registers the type mappings with the Unity container.</summary>
/// <param name="container">The unity container to configure.</param>
/// <remarks>There is no need to register concrete types such as controllers or API controllers (unless you want to
/// change the defaults), as Unity allows resolving a concrete type even if it was not previously registered.</remarks>
public static void RegisterTypes(IUnityContainer container)
{
// NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements.
// container.LoadConfiguration();
// TODO: Register your types here
// container.RegisterType<IProductRepository, ProductRepository>();
container.RegisterType<IUnitOfWork, UnitOfWork>(new PerRequestLifetimeManager());
container.RegisterType<IImportService, ImportService>(new PerRequestLifetimeManager());
container.RegisterType<IDataContext, PriceHunterDataContext>(new PerRequestLifetimeManager());
}
}
文件删除index.php
。
我的框架是codeigniter。
我的htaccess:
.htaccess
我的配置:
AddType application/x-httpd-php53 php53 php
php_flag log_errors on
php_flag display_errors on
#php_value error_reporting 8
php_value error_reporting E_ALL
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^megarooz.com/$ [NC]
RewriteRule ^(.*)$ http://megarooz.com/$1 [R=301,L]
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
</IfModule>
order allow,deny
allow from all
我收到了这条消息:
$config['base_url'] = 'http://megarooz.com';
$config['index_page'] = '';
它不起作用:
http://megarooz.com/admin/Admin/login
工作正常:
答案 0 :(得分:0)
尝试使用以下代码
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] // you have added / before index.php
</IfModule>
答案 1 :(得分:0)
试试这样....
1.在根文件夹中。 .htaccess
档案
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
2.在application/config/config.php
设置以下内容
$config['base_url'] = 'http://megarooz.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';
希望它有效。
答案 2 :(得分:0)
由于这是关于Stack的一个非常常见的问题,我希望您下次再进行一些研究,因为它充满了CI的index.php问题。尽管如此,我同意CI的htaccess有点不好,因为它对我来说并不总是有用,我最终做的就是从Laravel抓住htaccess。
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
从未遇到任何问题,希望这会有效。