udemethegrtman
udemethegrtman

Reputation: 107

pretty url not working on laravel5.2

It seems that pretty URLs are not working for me. I have tried every thing I know, when you try http://wasamar.com.ng/login it gives a response of 404 Not Found but http://wasamar.com.ng/inde.php/login is ok, I have edited my public/ directory's .htaccess file to this:

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

This is the /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 webmaster@localhost
        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>

What am I doing wrong?

Upvotes: 1

Views: 190

Answers (2)

udemethegrtman
udemethegrtman

Reputation: 107

thanks everyone for the support but i saw my error, in the /etc/apache2/apache2.conf file i did not add the AllowOverride All section the dirctory tags, when i fixed that it worked.

Upvotes: 0

sepehr
sepehr

Reputation: 18505

It's probably because your apache rewrite module is not enabled. To enable the rewrite module on a Ubuntu machine:

sudo a2enmod rewrite
sudo service apache2 restart

If a2enmod is not available on your platform, you need to open up your httpd.conf file and uncomment the line including rewrite_module. That's something like this on a macOS machine:

LoadModule rewrite_module libexec/mod_rewrite.so

Then you need to restart the service.

Also, for htaccess files to be effective you need to set AllowOverride directive to All. Here's an example:

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

Upvotes: 1

Related Questions