Apache: Virtual Host and .htacess for URL Rewriting not working
Posted
by
parth
on Pro Webmasters
See other posts from Pro Webmasters
or by parth
Published on 2011-05-15T18:44:55Z
Indexed on
2011/06/20
16:39 UTC
Read the original article
Hit count: 415
I have configured virtual host in my local machine and every thing working fine . Now I want to use SEO friendly urls. To achive this I have used .htacess file .
My virtual host configuration is :
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/ypp"
ServerName ypp.com
ServerAlias www.ypp.com
##ErrorLog "logs/dummy-host2.localhost-error.log"
##CustomLog "logs/dummy-host2.localhost-access.log" combined
</VirtualHost>
and my .htacess file has :
AllowOverride All
RewriteEngine On
RewriteBase /ypp/
RewriteRule ^/browse$ /browse.php
RewriteRule ^/browse/([a-z]+)$ /browse.php?cat=$1
RewriteRule ^/browse/([a-z]+)/([a-z]+)$ /browse.php?cat=$1&subcat=$2
The above .htacess setting is not working . After that I have modigied my virtual host setting and it is working . new virtual host setting is :
<VirtualHost *:80>
RewriteEngine On
RewriteRule ^/browse$ /browse.php
RewriteRule ^/browse/([a-z]+)$ /browse.php?cat=$1
RewriteRule ^/browse/([a-z]+)/([a-z]+)$ /browse.php?cat=$1&subcat=$2
ServerAdmin [email protected]
DocumentRoot "C:/xampp/htdocs/ypp"
ServerName ypp.com
ServerAlias www.ypp.com
##ErrorLog "logs/dummy-host2.localhost-error.log"
##CustomLog "logs/dummy-host2.localhost-access.log" combined
<Directory "C:/xampp/htdocs/ypp">
AllowOverride All
</Directory>
</VirtualHost>
Please guide me where I am wrong in .htacess file for url rewriting . I donot want to use setting in virtual host because for every change I have restart apache .
© Pro Webmasters or respective owner