Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.htaccess has been read but rewrite url is not working

the module in the httpd.conf for rewrite is as follow:

LoadModule rewrite_module modules/mod_rewrite.so

path to .htaccess:

c:\wamp\www\magentodev\.htaccess

therefore 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 of:

localhost/magentodev/gu/boombottleh2o.php

it supposed to work because it is working on production but not localhost, I have wamp server apache and here is some configurations:

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

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

it is not correct as Anu is saying so I am changed the 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 figure out what is wrong, I appreciate any help

like image 208
Nickool Avatar asked Jan 04 '16 23:01

Nickool


2 Answers

Have your C:/wamp/www/magentodev/.htaccess like this:

ErrorDocument 404 default
Options +FollowSymLinks
RewriteEngine on

RewriteRule ^boombottleh2o(/.*)?$ gu/boombottleh2o.php [NC,L]

mod_rewrite References:

  • Apache mod_rewrite Introduction
  • Apache mod_rewrite Technical Details
  • Apache mod_rewrite In-Depth Details
  • Apache mod_rewrite beginner's Tutorial
like image 99
anubhava Avatar answered Sep 28 '22 10:09

anubhava


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

Your .htaccess file looks solid for what you're trying to accomplish, but with your vhost.conf make sure to cover all your boundaries and add a regex * at the beginning of the file

So instead of

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

This eliminates localhost as you already set that as the ServerName and You can add an alias under neath

This may sound obvious but have you tried anything with the wampmanager?

Click on the Wamp Icon, then Apache, then modules and scroll down a bit and make sure the rewrite module has a check next to it. That fixed it for me!

Good Luck, Wamp is always trickier than it seems

like image 31
DaveeeF Avatar answered Sep 28 '22 09:09

DaveeeF