Reputation: 287
I have this code in my .htaccess
file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?link=$1 [L]
</IfModule>
And I am getting 404 although I can acces it with non-pretty url like this index.php?link=somepage
My full url is http://www.website.com/subfolder/index.php?link=somepage
I have Apache 2.4.18 on Ubuntu 16 and mod_rewrite
module is loaded.
Update
Also when I try with this:
RewriteRule ^ index.php [L]
Then I can access it with http://www.website.com/subfolder/?link=somepage
So this way it works when just removing index.php
Is it possible that some additional configuration has to be set on server?
Upvotes: 0
Views: 70
Reputation: 287
This was a server issue including mime types and multiviews.
It's not really issue for stackoverflow but if someone runs into same problems here are sources that solved this problem:
http://www.bennadel.com/blog/2218-negotiation-discovered-file-s-matching-request-none-could-be-negotiated.htm - remove MultiViews from Virtual Host configuration
https://serverfault.com/questions/372733/apache-file-negotiation-failed - add missing mime types
Upvotes: 1
Reputation: 2306
First of all you should check your apache config
sudo vi /etc/apache2/apache2.conf
Search for
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Change AllowOverride None to AllowOverride All
enable htaccess module by running cmd
sudo a2enmod rewrite
then restart your server
sudo service apache2 restart
and use this .htaccess file in your project folder
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/system.*
RewriteRule ^(.*)$ index.php?/$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php?/$1 [L]
Hope it works for u .. :)
Upvotes: 0
Reputation: 4089
Try with this:
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ ./index.php?link=$1
Upvotes: 0
Reputation: 41249
Try :
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /subfolder/index.php?link=$1 [L]
Upvotes: 0