2017-01-14 7 views
1

Кажется, что красивые URL-адреса не работают для меня. Я попробовал все, что я знаю, когда вы пытаетесь http://wasamar.com.ng/login это дает ответ 404 Not Found но http://wasamar.com.ng/inde.php/login это нормально, я редактировал файл .htaccess моей общественной директории/к это:pretty url не работает на laravel5.2

<IfModule mod_rewrite.c> 
    <IfModule mod_negotiation.c> 
     Options -MultiViews 
    </IfModule> 

    RewriteEngine On 

    # Redirect Trailing Slashes If Not A Folder... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)/$ /$1 [L,R=301] 

    # Handle Front Controller... 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteRule^index.php [L] 
</IfModule> 

Этот является /etc/apache2/sites-available/000-default.conf

<VirtualHost *:80> 
     # The ServerName directive sets the request scheme, hostname and port that 
     # the server uses to identify itself. This is used when creating 
     # redirection URLs. In the context of virtual hosts, the ServerName 
     # specifies what hostname must appear in the request's Host: header to 
     # match this virtual host. For the default virtual host (this file) this 
     # value is not decisive as it is used as a last resort host regardless. 
     # However, you must set it for any further virtual host explicitly. 

     ServerName wasamar.com.ng 

     ServerAdmin [email protected] 
     DocumentRoot /var/www/html/wasamar/public 

     # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 
     # error, crit, alert, emerg. 
     # It is also possible to configure the loglevel for particular 
     # modules, e.g. 
     #LogLevel info ssl:warn 

     ErrorLog ${APACHE_LOG_DIR}/error.log 
     CustomLog ${APACHE_LOG_DIR}/access.log combined 

     # For most configuration files from conf-available/, which are 
     # enabled or disabled at a global level, it is possible to 
     # include a line for only one particular virtual host. For example the 
     # following line enables the CGI configuration for this host only 
     # after it has been globally disabled with "a2disconf". 
     #Include conf-available/serve-cgi-bin.conf 
</VirtualHost> 

Что я делаю неправильно?

+0

Какова корневая папка вашего виртуального хоста Apache? –

+0

Где я могу это проверить? Это/etc/apache2, о котором вы говорите? – udemethegrtman

+0

Зависит от вашей ОС, например '/ etc/apache2/sites-available /' для Debian. –

ответ

1

Возможно, это связано с тем, что ваш модуль перезаписи apache не включен. Чтобы включить модуль перезаписи на машине Ubuntu:

sudo a2enmod rewrite 
sudo service apache2 restart 

Если a2enmod не доступна на вашей платформе, вам нужно открыть файл httpd.conf и раскомментировать строку, включая rewrite_module. Это что-то вроде этого на машине macOS:

LoadModule rewrite_module libexec/mod_rewrite.so 

Затем вам необходимо перезапустить службу.

Кроме того, для того, чтобы файлы htaccess были эффективными, вам необходимо установить директиву AllowOverride на номер All. Вот пример:

<Directory "/absolute/path/to/webserver/root"> 
    # ... 

    # 
    # AllowOverride controls what directives may be placed in .htaccess files. 
    # It can be "All", "None", or any combination of the keywords: 
    # AllowOverride FileInfo AuthConfig Limit 
    # 
    AllowOverride All 

    # ... 
</Directory> 
+0

Я сделал это * ** sudo a2enmod переписать ***, но проблема все еще выходит. – udemethegrtman

0

благодарит всех за поддержку, но я увидел свою ошибку, в файле /etc/apache2/apache2.conf я не добавлял разделу AllowOverride All в dirctory тегов, когда я установил, что он работал.

+0

Вот что я сказал в своем ответе, верно? – sepehr

+0

Да, в какой-то степени вы сказали .htaccess, но я исправил его в файле .apache2.conf. – udemethegrtman

+0

Нет, я этого не делал. Цитируйте: * 'для того, чтобы файлы htaccess были эффективными, вам нужно установить директиву AllowOverride для All.' *. – sepehr