views:

25

answers:

1

These should be a relatively easy task but I am having some serious issues with my muddled head on a friday. I have:

http://www.localokel.com/search.php?sch=city&val=London

and am trying to get:

http://www.localokel.com/search/city/London

Currently the following is not working:

RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /search.php?sch=$1&val=$2 [L]
+2  A: 

How about

RewriteRule ^/search/([^/]*)/([^/]*)$ /search.php?sch=$1&val=$2 [L]

Also don't forget you can debug the rewriting with RewriteLog.

Raoul Duke
For some reason this is still failing, could you explaing the location of RewriteLog
kalpaitch
It's a directive. So can define that for yourself. Like so: RewriteLog /path/to/my/arbitrary/logfile. http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html#rewritelog
Raoul Duke
@kalpaitch - The most likely reason it's failing is because you're defining the rule in `.htaccess`, and you need to remove the first `/` from the `RewriteRule` for it to ever match.
Tim Stone
@Raoul - The `RewriteLog` directive is very useful, but the OP appears to be on shared hosting, so it's likely they don't have access to the server configuration to set it.
Tim Stone
@kalpaitch - The browser is trying to resolve the stylesheets and javascript as if they were in the `/search/city` directory. It seems they are located relative to the site root, so if you put a `/` before them (e.g. `<link type="text/css" rel="stylesheet" href="/css/newstyles.css">`), they should show up fine.
Tim Stone
@Tim - top marks, thank you. I had realised this must be where the issue lay and so deleted my previous comment, but this is most definately the solution.
kalpaitch
@kalpaitch - No problem, glad it's working :)
Tim Stone