2014-01-13 48 views
0

我的项目(笨)在Windows 7上运行如何允许codeigniter查看我的.htaccess?

现在我的URL看起来像:

http://dev.something.com/index.php/reports 

,我想:

http://dev.something.com/reports 

我试图隐藏我的网址index.php以可以访问控制器。

从这个link我把.htaccess

所以我的.htaccess的样子:

Options +FollowSymLinks 
RewriteEngine on 
RewriteCond $1 !^(index\.php|app|robots\.txt) 
RewriteRule ^(.*)$ index.php/$1 [L] 

但这种改变并没有帮助我。

重要:

我清除所有数据从的.htaccess,但什么都没有发生。听起来像笨看不出.htaccess

.htaccess下我的根项目AE住宿:

C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\someprog_dev\.htaccess 

[编辑1]

同一项目工作正常的Linux所以它不是笨配置问题

[编辑2]

我改变.htaccess,以确保CodeIgniter使用.htaccess

<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /blogna/index.php/$1 [L] 
</IfModule> 

<IfModule !mod_rewrite.c> 
ErrorDocument 404 /index.php 
</IfModule> 

什么也没有发生。与index.php一起使用,但不是没有。

[编辑3]

httpd.conf样子:

.... 

LoadModule rewrite_module modules/mod_rewrite.so 

... 

LoadModule php5_module "c:/php/php5apache2_2.dll" 
<IfModule php5_module> 
    AddType application/x-httpd-php .php 
    PHPIniDir c:/php/ 
    DirectoryIndex index.php index.html 
</IfModule> 

我错过了什么?任何建议

+2

您是否启用了重写模块? –

+0

@balajimca重写模块的Apache? – snaggs

+0

是http://stackoverflow.com/a/3131259/817365 –

回答

0

这永远不会笨的工作对我以及..但下面做:

RewriteEngine On 
RewriteBase/
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ /index.php?/$1 [L] 

必要时更换

很好的参考路径:http://softkube.com/blog/url-rewriting-for-codeigniter/

0

尝试这些

RewriteEngine On 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php/$1 [L] 
0

我的。htaccess是如此简单

RewriteEngine on 
RewriteCond $1 !^(index\.php|images|css|robots\.txt|js|files|icons|images) 
RewriteRule ^(.*)$ /pathtoapp/index.php?/$1 [L] 

和完美的作品。但是您需要正确设置CI配置文件中的所有内容,并且该规则必须与您的$config['base_url']匹配。

所以,如果你有

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

你必须把

RewriteRule ^(.*)$ /myapp/index.php?/$1 [L] 
+0

代码在Linux上运行的问题。我无法更改项目配置。 – snaggs

+0

所以它看起来像一个环境相关的问题。在Linux上它是否属于与根相同的相对路径?在Apache上有没有不同的重定向? (你已经在Win7上提到mod_rewrite是可以的) –

0

试试这个htaccess.It的运作良好。

DirectoryIndex index.php 
RewriteEngine on 
RewriteCond $1 !^(index\.php|images|css|js|robots\.txt|favicon\.ico) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ ./index.php/$1 [L,QSA] 

将index.php更改为任何主控制器。