.htaccess has been read but rewrite url does not work

The module in httpd.conf to rewrite is as follows:

LoadModule rewrite_module modules/mod_rewrite.so 

path to .htaccess:

c:\wamp\www\magentodev\.htaccess

so in .htacess I have this:

 <IfModule mod_rewrite.so> Options +FollowSymLinks RewriteEngine on RewriteCond %{REQUEST_URI} ^/boombottleh2o\+?$ RewriteRule (.*) /gu/boombottleh2o.php [NC,L,QSA] //some other ones </IfModule> 

I expected to try:

 localhost/magentodev/boombottleh2o 

instead:

 localhost/magentodev/gu/boombottleh2o.php 

it should work because it works on production, but not localhost, I have a wamp server server, and here are a few configurations:

in C: \ wamp \ bin \ apache \ apache2.4.9 \ conf \ httpd.conf:

 <Directory "c:/wamp/www/"> Options Indexes FollowSymLinks AllowOverride All Require local </Directory> 

this is incorrect, since Anu says that I changed it in C: \ wamp \ bin \ apache \ apache2.4.9 \ conf \ extra \ httpd-vhosts.conf to:

 <Directory "C:/wamp/www/"> Options All AllowOverride All Order allow,deny Allow from all </Directory> <VirtualHost *:80> ServerAdmin localhost DocumentRoot C:/wamp/www/ ServerName localhost </VirtualHost> 

I could not understand what was wrong, I appreciate any help

+6
source share
3 answers

Enter C:/wamp/www/magentodev/.htaccess as follows:

 ErrorDocument 404 default Options +FollowSymLinks RewriteEngine on RewriteRule ^boombottleh2o(/.*)?$ gu/boombottleh2o.php [NC,L] 

mod_rewrite Links:

+5
source

I had a similar problem on my Wamp ver 2.5 server with Windows 7 ..

Your .htaccess file looks convincing for what you are trying to execute, but with your vhost.conf be sure to include all your borders and add the regular expression * to the top of the file

So instead

<Virtualhost localhost: 80>
You get <VirtualHost *: 80>

This eliminates the local host, as you already set it as ServerName, and you can add an alias under neath

This may seem obvious, but have you tried anything with wampmanager?

Click the Wamp icon, then Apache, then the modules and scroll down a bit and make sure the rewrite module has a checkbox next to it. It fixed it for me!

Good luck, wamp is always harder than it sounds

+2
source

It looks like your RewriteCond is expecting http://localhost/boombottleh2o/ , not the URL that you used localhost/magentodev/boombottleh2o , because the REQUEST_URI line will contain /magentodev/boombottleh2o , but your regular expression expects /boombottleh2o to match the very beginning of the line.

To fix this condition, you need to remove the carat ^ .

You also avoid the + character at the end of your regular expression. \+? will try to combine the character + 0 or once. I'm not sure if it was intentional, but if you use .*? , you will always match the query for the / boombottleh 20 / folder, even if the query goes deeper or includes a file type

Tl; dr - I think your RewriteRule should look like this:

 RewriteCond %{REQUEST_URI} /boombottleh2o.*?$ 
+1
source

All Articles