1

I have a local environment working fine. Pasted a test route in .htaccess and it works as expected (re-routes me to google).

RewriteEngine on
RewriteRule testpage\.html http://www.google.com [R]

I pasted the same thing on my development server (Unbutu 12.04) and it simply gives me a Not Found page. When I verify it on the devserver by running:

sudo a2enmod rewrite

It says "Module rewrite already enabled".

Edit: It also appears in the "loaded modules" section of phpinfo() and I have restarted the apache server several times since it was installed.

Any ideas?

3 Answers 3

5

Most likely it is because mod_rewrite is enabled but .htaccess files are disabled via

AllowOverride None

which disables checking .htaccess files (which gives You some performance gains but You have to put Your mod_rewrite code directly in apache configuration files)

Change for Your virtual host to:

AllowOverride All
0
2

For people who don't understand - http://victorpotapov.ru/blog/vkljuchaem_mod_rewrite_v_apache/2013-11-03-61

On this page you can see step by step, that you enter in your terminal on ubuntu

2
  • The relevant content from that page should be added to the answer Commented Nov 26, 2013 at 9:01
  • its not about understanding , if you have this problem , follow the link on this answer ! Commented Apr 30, 2014 at 20:29
2

enable mod_rewrite

Activate the mod_rewrite module with

sudo a2enmod rewrite

and restart apache

sudo service apache2 restart

Edit virtual host to use mod rewrite within .htaccess

sudo nano /etc/apache2/sites-available/000-default.conf

Search for "DocumentRoot /var/www/html" and add the following lines

<Directory "/var/www/html">
AllowOverride All
</Directory>

Save & Exit CTRL-X, "Y" and Enter

Restart Apache

sudo service apache2 restart

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.