views:

51

answers:

1

I am working on a site maintainence. It uses mod_rewrite technique. But im new to mod_rewrite. How should i change the url to work correctly in my localhost. here's the code:

# Enable mod_rewrite, start rewrite engine 
Options +FollowSymLinks 
RewriteEngine on 

rewritecond %{http_host} ^electricians4u.com.au [nc]
rewriterule ^(.*)$ http://www.electricians4u.com.au/$1 [r=301,nc]

ErrorDocument 404 /error404.php

# for searching
RewriteRule ^([^/]*)-in-([^/]*)\.htm$   /search.php?searchby=$1&SearchString=$2&search.x=$3&search.y=$4&search=Find+Agent [NC] 

# for nav
RewriteRule ^electricians-in-([^/]*)-([^/]*)$ /search.php?SearchString=$1&state=&page=$2          [NC] 

# index page
RewriteRule ^find-electrician-(.*)$ /find_electrician_in.php?state=$1                    [NC,L] 

# find  page
RewriteRule ^electrician-(.*)-(.*)$ /find_electrician_in.php?state=$1&bspname=$2         [NC,L] 

# find  page
RewriteRule ^electricians-in-([^/]*)\.htm$ /search.php?state=$1&bspname=$2&locality=$3     [NC] 

Plz help. I know this silly question to ask. But i dont know other alternative.

A: 

I don't see why this shouldn't work, if everything else is correctly configured otherwise, and all the files installed. There is nothing specific in there. The explicit reference to the .co.au domain won't apply.

Just make sure you have the mod_rewrite module activated in your Apache configuration.

Pekka
actually im working on localhost, i think i had to edit the domain into localhost. BUt i dont know exactly
Rajasekar
@Rajasekar: Have you put the project somewhere else than directly in the DocumentRoot of localhost? It would not work in a subdirectory.
maligree
my root is at http://localhost/elec, whether i had to change anythin in rewrite_con, since it had some URL of domain
Rajasekar
Then try `RewriteBase /elec/` directly after RewriteEngine.
maligree