...

View Full Version : Mod rewrite - using server URL



ab123
11-02-2010, 10:36 AM
I'm trying to rewrite a wierd URL i haven't done before i think its conflicting with the curly character.

The url is:

http://ftp2.domains.net/~insurance/index.php?insurancetype=restaurants-insurance&county=cheshire

I wanted to turn this url, using .htaccess into SEO friendly such as:

http://ftp2.domains.net/~insurance/restaurants-insurance/cheshire

I have tried counless menthod to achive this with no luck.

I have tryed this and others.

RewriteRule /(.*)/$ /\~insurance/index.php?insurancetype=$1

Thanks the help. much appreciated.

120
11-02-2010, 09:42 PM
The symbol is called 'Tilde' (usually pronounced 'tilda') and I would wonder why you are escaping it in the substitution. Now in the match would be something different :-)

Basically what you have there won't work. Say you call up

blah.net/~insurance/index.php?insurancetype=restaurants-insurance&county=cheshire

Your rewrite - if it worked -would (I think) try and translate that URL to something like this:

blah.net/\~insurance/index.php?insurancetype=blah.net/~insurance/index.php?insurancetype=restaurants-insurance&county=cheshire
The backslash would probably result in a 404 (or even a 500 internal) error.

Depending on how many querystring elements you have I would look at using RewriteCond to do the matching making use of %{QUERY_STRING} and back references.

This will give you a pointer: http://www.simonecarletti.com/blog/2009/01/apache-rewriterule-and-query-string/



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum