Well, I'm new to Drupal, I was wondering if I can add values to header?

Note: this is the code for my mysite.com

I got this piece of code in mysite.com


    if (isset($_GET['code'])) {
    echo $_GET['code'];


So for example,

Drupal URL:


If I run that URL, it redirects me to PAGE 404

So I tried this, URL:


Which it eventually works.

So I tried using RewriteRule thing in .htaccess and added this code

RewriteEngine on
RewriteRule ^([a-zA-Z0-9]+)$ index.php?code=$1

Even change it into

RewriteEngine on
RewriteRule ^([a-zA-Z0-9]+)$ ?code=$1


RewriteEngine on
RewriteRule ^([a-zA-Z0-9]+)$ http://www.mysite.com/?code=$1

None of it works.

Plus I don't know where to put that piece of code in existing .htaccess that Drupal made it.

So to simplify, what I want is:

If I access mysite.com/U2pVnWK I would be able to retrieve and echo U2pVnWK instead of redirecting to PAGE 404 PAGE

Any help would be appreciated. :)


There is something you can try with Drupal itself.


Alters inbound URL requests.

The idea is to drupal_lookup_path and if nothing found you can do whatever with $path variable in hook_url_inbound_alter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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