form GET to seo urls?

PHP coding talk.

Moderator: Moderators

form GET to seo urls?

Postby Link on Thu May 31, 2007 6:07 pm

I'm using mod_rewrite to change database.php to /database/ the page has a form to filter results using the GET method. However the URL looks like /database/?filter=id&order=asc which basically doesn't work. I would like it to look like /database/id/asc/ but how would you do this using the GET method?
Link
Registered User
Registered User
 
Posts: 31
Joined: Sat Sep 10, 2005 8:43 pm

Postby DooBDee on Thu May 31, 2007 8:13 pm

Alter PHP Script to generate the directory listing instead of the dynamic parameters

Then try this (im not expert with mod_rewrite) so not sure if it will work.

Code: Select all
Options +FollowSymLinks
RewriteEngine on
RewriteRule database/(.*)/(.*)/$ /database.php?filter=$1&order=$2
DooBDee
Website Ninja
DooBDee.net
User avatar
DooBDee
Moderator
Moderator
 
Posts: 3530
Joined: Tue Mar 01, 2005 6:28 pm
Location: DooBDee.net

Postby Link on Thu May 31, 2007 8:36 pm

[quote user="DooBDee" post="89880"]Alter PHP Script to generate the directory listing instead of the dynamic parameters
[/quote]

That's the problem; I don't know how I can do this.
Link
Registered User
Registered User
 
Posts: 31
Joined: Sat Sep 10, 2005 8:43 pm

Postby DooBDee on Thu May 31, 2007 8:44 pm

Are you using just normal links, or are you using something like <form method="get"...

Edit: Nevermind above...i didn't read topic title.

Only way I can think of doing that for now is to; change method="get" to method="post". Then using $_POST['submit'] or whatever, you can create the URL string, then use header('Location .... '); and then exit; to redirect to friendly URL. That page processing must be done before any HTML otherwise it wont be able to redirect to friend URL.
DooBDee
Website Ninja
DooBDee.net
User avatar
DooBDee
Moderator
Moderator
 
Posts: 3530
Joined: Tue Mar 01, 2005 6:28 pm
Location: DooBDee.net

Postby Link on Thu May 31, 2007 8:49 pm

Code: Select all
<form action="/database/" method="get">
Order by:
<select name="order">
<option value="id">id</option>
<option value="name">Name</option>
<option value="rank">Rank</option>
</select>
<select name="orderby">
<option value="asc">Ascending Order</option>
<option value="desc">Descending Order</option>
</select>
<input type="submit" value="submit" />


I was originally using $PHP_SELF but i found that /database/ worked better.
Link
Registered User
Registered User
 
Posts: 31
Joined: Sat Sep 10, 2005 8:43 pm

Postby DooBDee on Thu May 31, 2007 8:50 pm

Hi Link,

See my edited post above, sorry, I forgot you mentioned "form" already. Any problems, just reply. :)
DooBDee
Website Ninja
DooBDee.net
User avatar
DooBDee
Moderator
Moderator
 
Posts: 3530
Joined: Tue Mar 01, 2005 6:28 pm
Location: DooBDee.net

Postby Link on Thu May 31, 2007 9:03 pm

Yup that works, thanks for the help.
Link
Registered User
Registered User
 
Posts: 31
Joined: Sat Sep 10, 2005 8:43 pm

Thanks

Postby freeadnetwork on Wed Jul 16, 2008 4:30 am

Works thanks.. for the support.
Journalism College - MIT - ISBJ offers courses in journalism like Post graduation courses and M.A in Masters of Journalism.
freeadnetwork
Registered User
Registered User
 
Posts: 3
Joined: Wed Jul 16, 2008 4:22 am

Re: form GET to seo urls?

Postby DooBDee on Sun Aug 24, 2008 6:24 pm

You're welcome!
DooBDee
Website Ninja
DooBDee.net
User avatar
DooBDee
Moderator
Moderator
 
Posts: 3530
Joined: Tue Mar 01, 2005 6:28 pm
Location: DooBDee.net

Re: form GET to seo urls?

Postby sherinmary4 on Fri Apr 10, 2009 12:55 pm

very informative :) thank you :)

seo training
sherinmary4
Registered User
Registered User
 
Posts: 1
Joined: Wed Apr 01, 2009 9:36 am


Return to PHP Programming

Who is online

Users browsing this forum: No registered users and 3 guests

cron