Reputation: 3
I am fairly new to php and RewriteRules, I tried to make localhost/webapp/sign_up.php point to localhost/webapp/sign_up. This is my .htaccess code:
RewriteEngine On
RewriteRule ^sign_up/?$ sign_up.php
but when I go to localhost/webapp/sign_up it says:
Not Found
The requested URL /webapp/sign_up was not found on this server.
I am using apache2 (Ubuntu) by the way and I am sure rewrite_mod is enabled.
In case it helps, my .htaccess is under var/www/html/webapp
Upvotes: 0
Views: 602
Reputation: 1769
Try this and let me know
RewriteEngine On
RewriteBase /webapp/
RewriteRule ^([a-z_]+)/?$ $1.php [NC,L]
And make sure the mod_rewrite module is enabled by running these commands
sudo a2enmod rewrite
sudo service apache2 restart
And if all else fails please try setting a virualhost and after read this article about setting up mod_rewrite
Upvotes: 1
Reputation:
I guess this will help more:
RewriteRule ^([^\.]+)$ $1.php [NC,L]
It allows you to put the .php away everywhere
Upvotes: 0