poleposters Posted November 2, 2009 Share Posted November 2, 2009 Hi, I was wondering if it was possible to generate a flat URL from a from using the method GET. I've had some experience using mod-rewrite to create flat URLs from links e.g www.domain.com/blog/id/1 is interpreted as www.domain.com/blog.php?id=1 But how do I do it the other way around? ie. When I submit a form using the get method its going to generate a messy URL. Can I get the form to generate a flat URL? Quote Link to comment https://forums.phpfreaks.com/topic/179906-query-string-from-a-form-get-method-to-flat-url/ Share on other sites More sharing options...
MadTechie Posted November 2, 2009 Share Posted November 2, 2009 If its from a form then your need to use some Javascript.. it really depends what your trying to do, Quote Link to comment https://forums.phpfreaks.com/topic/179906-query-string-from-a-form-get-method-to-flat-url/#findComment-949048 Share on other sites More sharing options...
poleposters Posted November 2, 2009 Author Share Posted November 2, 2009 I was afraid someone might mention javascript. Mainly I'd like to make the URLs look clean and tidy and with any luck gain some advantage in SEO. I just had an idea to use an intermediary page to process the form data and spit out a a flat URL to complete the query. ie the form data www.domain.com/blog.php?id=1 is passed to intermediate.php and transfomed and redirected to www.domain/blog/id/1/ where the query is completed. Are there any cons to this method? Quote Link to comment https://forums.phpfreaks.com/topic/179906-query-string-from-a-form-get-method-to-flat-url/#findComment-949074 Share on other sites More sharing options...
Jnerocorp Posted November 2, 2009 Share Posted November 2, 2009 im not entirely sure but i believe it is possible to do what you are trying to do with the .htaccess to any experts what I believe he means is he wants his links to look like this: "www.domain/blog/id/1/" instead of this: "www.domain.com/blog.php?id=1" -John Quote Link to comment https://forums.phpfreaks.com/topic/179906-query-string-from-a-form-get-method-to-flat-url/#findComment-949076 Share on other sites More sharing options...
MadTechie Posted November 2, 2009 Share Posted November 2, 2009 @Jnerocorp, your correct but i don't believe thats what his asking for .. when you post from a form the URL the form goes to (VIA GET) is like index.php?id=10&name=blar, Now while you can change the URL in an anchor tag, its not really possible to do it in a form.. but you could have a javascript collect all the form elements and build up a query and use windows.locations= "page.php?"+buildUpQuery Quote Link to comment https://forums.phpfreaks.com/topic/179906-query-string-from-a-form-get-method-to-flat-url/#findComment-949098 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.