2017-02-17 1 views
1

Ich möchte mod_rewrite verwenden, aber scheint, dass nicht funktioniert, ich habe es aktiviert und ich in meinem .htaccess eingerichtet, aber nichts scheint zu funktionieren. Ich will nicht index.php in meiner URL anzuzeigen: stattApache mod_rewrite funktioniert nicht

localhost/index.php/admin/login 

I

localhost/admin/login 

Ich bin unter Ubuntu hier angezeigt werden soll ist, was mein phpinfo() sagt:

enter image description here

Das ist mein .htaccess:

# Make sure directory listing is disabled 
Options +FollowSymLinks -Indexes 
RewriteEngine on 

#RewriteBase /virtualpost 
RewriteCond %{HTTP_HOST} ^localhost$ 
RewriteRule . - [E=REWRITEBASE:/virtualpost] 

#RewriteBase/
RewriteCond %{HTTP_HOST} ^((?!localhost).)*$ 
RewriteRule . - [E=REWRITEBASE:/] 

# Remove index.php from URL 
RewriteCond %{HTTP:X-Requested-With} !^XMLHttpRequest$ 
RewriteCond %{THE_REQUEST}    ^[^/]*/index\.php [NC] 
RewriteRule ^index\.php(.*)$   $1 [R=301,NS,L] 

# Keep people out of codeigniter directory and Git/Mercurial data 
RedirectMatch 403 ^/(system\/virtualpost\/cache|system\/codeigniter|\.git|\.hg).*$ 

# Send request via index.php (again, not if its a real file or folder) 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

<IfModule mod_php5.c> 
    RewriteRule ^(.*)$ index.php/$1 [L] 
</IfModule> 
<IfModule !mod_php5.c> 
    RewriteRule ^(.*)$ index.php?/$1 [L] 
</IfModule> 

Das ist mein /etc/apache2/sites-available/000-default.conf:

<VirtualHost *:80> 
    SetEnv MYSQL_DB_HOST localhost 
    SetEnv MYSQL_USER root 
    SetEnv MYSQL_PASSWORD spaces 
    SetEnv MYSQL_DB_NAME clevvermail 
    <Directory ...> 
     AllowOverride All 
    </Directory> 
    DocumentRoot /var/www 
    ErrorLog ${APACHE_LOG_DIR}/error.log 
    CustomLog ${APACHE_LOG_DIR}/access.log combined 
    LoadModule rewrite_module modules/mod_rewrite.so 
</VirtualHost> 
+0

nicht gefunden wurde Die angeforderte URL/admin/login auf diesem Server nicht gefunden. – bourax

+0

Überprüfen Sie, ob Ihr '.htaccess 'wirklich aktiviert ist oder nicht, indem Sie etwas Müll (zufälligen) Text über Ihre' .htaccess' legen und sehen, ob beim Aufruf Ihrer Seite im Browser ein Fehler von 500 (interner Server) auftritt . 500 Fehler bedeutet, dass .htaccess aktiviert ist. – anubhava

+0

hmmm, nein, ich habe 500 Fehler nicht bekommen. Wie sollte ich also .htaccess aktivieren? – bourax

Antwort

2

Ich fand heraus, dass ich die apache2 config hatte. conf Datei /etc/apache2/apache2.conf and change

<Directory /var/www/> 
    Options Indexes FollowSymLinks 
    AllowOverride None <<-- Rewriting desactivated 
    Require all granted 
</Directory> 

zu

<Directory /var/www/> 
    Options Indexes FollowSymLinks 
    AllowOverride All <<--Activate rewriting 
    Require all granted 
</Directory>