Log in

View Full Version : urlrewrite virtual folders and form submit



Dennis_Gull
11-12-2008, 11:04 AM
Hi,
Im currently working on a project where I want to add virtual folders in some sections, for example:
example.com/fake/topic-23.html
<domain>/<fake folder>/<some topic with an id>
however If I add a form to this topic-23.html page I will have to point it somewhere and even if I point it to /fake/ it will look like this:
<domain>/<fake folder>/<my GET values>

so is there some way I can urlrewrite the form submit action? :)
for example if I want it to go here:
example.com/fake/search/<search value>/topic-23.html

// Dennis

maneetpuri
11-12-2008, 12:07 PM
Hi,

I am assuming that your using PHP for this development on a Linux Server, there are two ways to do this: -

a) Do URL parsing and redirecting in your .htaccess file, for this you will need to do some programing for apache and
b) In your .htaccess define a specific PHP script and in this PHP script parse the query string and redirect to whatever page you want.

I suggest the first one as it more friendly for search engine crawlers.

Hope this helps.

Cheers,

~Maneet
LeXolution IT Services
Web Development Company (http://www.lexolutionit.com)

Dennis_Gull
11-13-2008, 01:50 PM
Thanks for the reply, I didn't think about using the .htaccess file to redirect them.
Btw lets say I have a page which is rewritten and says /topic/I_eat_pie-24.html

won't I have to store the "fake" name in a hidden input field then?
because all the .htaccess file will see is topic.php?id=24&search=<blabla>

Dennis_Gull
11-25-2008, 09:32 AM
Scratch that last question, how can I even redirect someone with the htaccess file?
I've been looking for ages for this but cant find anything usefull.
I thought [R=301] would redirect them for good but that didn't work at all.
example:

RewriteRule ^(search)/(.*)$ search.php?id=$2 [R=301,L]