5

I've found a post which explains how to pass a parameter/argument/referer to webform.

It works fine, but I get an ugly URL. Is there any way to do this using a clean URL? I mean without using GET parameters.

2 Answers 2

4

You could solve this using mod_rewrite in your .htaccess file. Try something like

RewriteCond %{REQUEST_URI} ^/path/to/your/webform/(value)$
RewriteRule ^.*$ /path/to/your/webform?param=%1 [L]

This way you can do many things but you can't configure that with the drupal UI. Here's an example with more paramters:

RewriteCond %{REQUEST_URI} ^/path/to/your/webform/(value1)/(value2)/(.*)$
RewriteRule ^.*$ /path/to/your/webform?param1=%1&param2=%2&param3=%3 [L]

Check out the manual.

EDIT: your comment example should look something like that:

RewriteCond %{REQUEST_URI} ^/myform/(\d+)$ 
RewriteRule ^.*$ /myform?i=%1 [L] 

The exact regex at the end depends on your parameters. If you expect only numbers like 1 or 0125 \d+ should be fine. Check out this cheatsheet for more/other char-classes and regex stuff.

4
  • Hi nonsenz, I tried to implement your code like: RewriteCond %{REQUEST_URI} ^ficha_inmueble/(value1)$ RewriteRule ^.*$ ficha_inmueble?param1=%1 [L] The url to rewritte is: localhost/drupal6multilingual/myform/111 But not working... The url using get parameters is: localhost/drupal6multilingual/myform?i=111
    – chefnelone
    Jun 10, 2011 at 8:53
  • sorry for my unclear previous comment but break lines doesn't work right when adding comments (i'm using chrome)
    – chefnelone
    Jun 10, 2011 at 9:01
  • I misstyped: where it says ficha_inmueble read myform
    – chefnelone
    Jun 10, 2011 at 9:03
  • EDIT: it's not working but I think that reason is I have the webform inside a Panel Page, then drupal makes a different url path that the one I see in the browser address bar. Anyway your answer has been useful to me.
    – chefnelone
    Jun 10, 2011 at 12:19
2

Drupal strictly recognize the q i.e. $_GET['q'] as the page path otherwise redirects to Page Not Found page. Passing the arguments as part of q, Drupal menu system must be aware of such arguments place holders. And there arguments can be accessed by arg([arg-index])

Passing extra unregistered parameter to any page is only possible by additional GET variables beside q and can be accessed by PHP's regular way. i.e. $_GET global array

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.