2015-06-19 30 views
1

现在,网址为我的网站是例如:http://localhost/xxx/index.php/welcome/mod_rewrite的笨

我想这个更改为:http://localhost/xxx/welcome/

我的.htaccess文件:

<IfModule authz_core_module> 
    Require all denied 
</IfModule> 
<IfModule !authz_core_module> 
    Deny from all 
</IfModule> 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 

我的config.php文件:

$config['base_url'] = 'http://localhost/xxx/'; 
$config['index_page'] = ''; 

但我的新网址仍然无效。我应该在那里添加什么?

+1

这个问题可能有助于消除http://stackoverflow.com/questions/30933255/codeigniter-removing-index-php-from-url的index.php一直问数百次堆栈过流。不要触摸应用程序文件夹中的htaccess。 – user4419336

+1

实际上是否有效?你为什么拒绝访问该网站? “要求全部拒绝” –

回答

2

你可以尝试下面的mod_rewrite。它实际上工作,我看到了我看到的一个教程here,这里是.htaccess。

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /foldername/foldernameifapplicable/foldernameifapplicable 

#Removes access to the system folder by users. 
#Additionally this will allow you to create a System.php controller, 
#previously this would not have been possible. 
#'system' can be replaced if you have renamed your system folder. 
RewriteCond %{REQUEST_URI} ^system.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

#When your application folder isn't in the system folder 
#This snippet prevents user access to the application folder 
#Submitted by: Fabdrol 
#Rename 'application' to your applications folder name. 
RewriteCond %{REQUEST_URI} ^application.* 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

</IfModule> 

<IfModule !mod_rewrite.c> 
    # If we don't have mod_rewrite installed, all 404's 
    # can be sent to index.php, and everything works as normal. 
    # Submitted by: ElliotHaughin 

ErrorDocument 404 /index.php 
</IfModule>  
+0

尽管此链接可能回答此问题,但最好在此处包含答案的基本部分,并提供供参考的链接。如果链接页面更改,则仅链接答案可能会失效。 – bytecode77

+0

ooops。对不起。我会编辑它,顺便说一句,感谢提醒, – Noobie