Run
Run

Reputation: 57176

Apache mod_rewrite is enable on server but not working?

I have recently installed the lamp stack and have enabled mod_rewrite:

$ sudo a2enmod rewrite
$ service apache2 restart

I can see it on my phpinfo:

enter image description here

But when I try to access an URL like this below in my WordPress:

http://my-localhost/my-wordpress/whats-on/

I get this error:

Not Found

The requested URL /my-wordpress/whats-on/ was not found on this server.

Apache/2.4.18 (Ubuntu) Server at 127.0.0.1 Port 80

What else can I do? Have I missed anything?

Any ideas?

I have my .htaccess on too:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /my-wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /my-wordpress/index.php [L]
</IfModule>

# END WordPress

But why?

EDIT:

I created a simple test:

RewriteRule ^test.html$ test.php [L] 

But i get 404 error instead of being directed to test.php

Not Found

The requested URL /mod_rewrite/basic/test.html was not found on this server.

Apache/2.4.18 (Ubuntu) Server at 127.0.1.1 Port 80

How can I fix this?

Upvotes: 2

Views: 6503

Answers (1)

exclussif
exclussif

Reputation: 51

To fix this issue follow this:

sudo nano /etc/apache2/apache2.conf

Find:

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

Replace With:

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

Exit and save and restart apache with command

sudo systemctl restart apache2

THE END :-)

Upvotes: 5

Related Questions