2012-04-13 12 views
0

Ich tat, was es in der .htaccess gesagt:codeigniter zu umleiten pflegt eine URL

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

ich die oben setzen, so dass ich in der Lage sein wird, dies zu tun:

http://localhost/Speakom2/Home/index 

Statt:

Aber es funktioniert nicht ... Ich bekomme 404 Fehler..wie zu beheben, damit es funktioniert?!?

Controller:

class Home extends CI_Controller { 

public function Index() 
{ 
    $this->load->view('welcome_message'); 
} 

}

.htaccess:

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

möglich Duplikat [CodeIgniter .htaccess Unterordner Problem] (http://stackoverflow.com/questions/7527491/codeigniter-htaccess-subfolder-problem) – Ben

Antwort

1

, wenn Sie auf dem lokalen Rechner ausgeführt werden Web-Stamm /localhost/mysite/ ist aber in der realen Host Ihre Wurzel ist /mysite: so in localhost verwenden:

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

beachten Sie, dass index.php ohne /

+0

siehe Update ...... –

+0

NICE ANTWORT, NETTE ERKLÄRUNG –

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

// Das ist .htaccess es nur ersetzen RewriteEngine On RewriteBase //

#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] 

#Checks to see if the user is attempting to access a valid file, 
#such as an image or css document, if this isn't true it sends the 
#request to index.php 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule ^(.*)$ index.php?/$1 [L] 

1

Stellen Sie sicher, dass Ihre .htaccess Datei ist in Speakom2 Ordner (Codei gniter root-Verzeichnis). Und auf diese

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

Ihre Lösung hat funktioniert ... danke –