2017-01-02 154 views
2

当我在浏览器中使用本地主机/小时运行CI项目时,它将本地主机/仪表板/重定向到CodeIgniter本地主机重定向到xampp主屏幕

搜索不同的解决方案,但没有得到它的工作。这里是我的.htaccess文件 “的htdocs /小时” 文件夹

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

注:没有的.htaccess文件的htdocs文件夹。

当我删除/重命名index.php文件和访问htdocs它给我错误。

Object not found! 

The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again. 

我在做什么错,如何让它工作?我htdocs中的

截图/小时文件夹是波纹管

enter image description here

+0

你的route.php中有什么 – Snm

+0

'$ route ['default_controller'] =“site”; $ route ['404_override'] ='';' –

+0

'在'RewriteEngine On'后面加上'RewriteBase/hr /' – Kamran

回答

4

我知道我是一个一年后回答这个。但上面的答案都没有说明你实际需要做些什么才能解决这个问题。我在提供答案以防将来帮助别人。

解决方案:

你需要在你的文件夹中的.htaccess文件是你的情况(CI)来设置重写基地。

所以,你会目前有

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase/

您应将其更改为

<IfModule mod_rewrite.c> 
    RewriteEngine On 
    RewriteBase /ci/ 

就是这样。它现在会工作。

+0

真的很欣赏男人:) –

+0

很高兴帮助:) – shazyriver

+0

@NomanAli你应该接受这个答案,如果它解决了你的问题,这将有助于未来的游客。 – shazyriver

2

看一看RewriteBase directive然后试试这个:

RewriteEngine on 
RewriteBase /hr/ 

RewriteCond %{REQUEST_URI} !^(index\.php|images|robots\.txt) 
RewriteRule ^(.*)$ /index.php/$1 [L] 

另外,你需要确保Apache的重写模块启用:

# Check if it's enabled: 
apachectl -M | grep rewrite 

# You might need sudo here: 
a2enmod rewrite 

# On platforms that a2enmod is not available, you need 
# to open up your httpd.conf file and uncomment the line 
# that looks like this: 
LoadModule rewrite_module libexec/mod_rewrite.so 
0

您需要启用php重写模块。要启用请按照我这样的回答:

Run a CodeIgniter project issue

+0

尽管这个链接可能回答这个问题,但最好在这里包含答案的重要部分,链接供参考。如果链接页面更改,则仅链接答案可能会失效。顺便说一句,PHP没有重写模块。 – sepehr

相关问题