Reputation: 2055
I have been trying for the past few hours to write clean URLs in my LAMP machine.
Apache's mod_rewrite is enabled, and I am trying to use an .htaccess file to pass the URL GET parameters to my index.php script which at the time is just a var_dump of _GET.
My current .htaccess is the following (although I've tried quite a few variations of it I found on other answers with no success)
RewriteEngine On
#Make sure it's not an actual file
RewriteCond %{REQUEST_FILENAME} !-f
#Make sure its not a directory
RewriteCond %{REQUEST_FILENAME} !-d
#Rewrite the request to index.php
RewriteRule ^(.*)$ index.php?/get=$1 [L]
When I point my browser to localhost/my_project/test, all I get is a 404 error saying:
Not Found
The requested URL /my_project/test was not found on this server.
Apache/2.2.22 (Ubuntu) Server at localhost Port 80
Apparently I'm missing something obvious here, any help?
Upvotes: 3
Views: 4153
Reputation: 785721
2 things to look for:
my_project
directory.Then add RewriteBase
line as well:
RewriteEngine On
RewriteBase /my_project/
#Make sure it's not an actual file
RewriteCond %{REQUEST_FILENAME} !-f
#Make sure its not a directory
RewriteCond %{REQUEST_FILENAME} !-d
#Rewrite the request to index.php
RewriteRule ^(.*)$ index.php?get=$1 [L]
Upvotes: 3