Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Apache RewriteRule or RewriteCond

Apache RewriteRule or RewriteCond

Apache RewriteRule or RewriteCond


I've been trying to craft a RewriteRule to alleviate an issue we're seeing with some inbound links. Something is appending ?null to the URL.

I tried several RewriteCond and RewriteRule options I could think of to no avail. A sample URL is:


which should instead be:



So essentially a ? should be put in place of the ; and the ?null should be stripped off.

Any help would be greatly appreciated.



RE: Apache RewriteRule or RewriteCond

Please edit the post and 'break' the auto linking so we can see the URI.


Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.

RE: Apache RewriteRule or RewriteCond


This works for me :

CODE --> .htaccess

RewriteRule "(.+);(.*)" "$1?$2" 


RE: Apache RewriteRule or RewriteCond

Hi Feherke,

Thank you for the tip. I had no such luck with the RewriteRule running Apache 2.2.15.

Also, I don't think the rule you mentioned would also strip off any trailing ?null string, but I suspect that could be a 3rd variable you add to the string.

Any other suggestions?



RE: Apache RewriteRule or RewriteCond


Quote (John)

Also, I don't think the rule you mentioned would also strip off any trailing ?null string
Not explicitly, but due to the rule's effect it disappears.

But now that you emphasized on this, maybe should had asked before : what exactly you want ? The rule I wrote it performs mod_rewrite's default action : rewrites. Do you want it redirected instead ?

Quote (John)

Any other suggestions?
Try again.

I use Apache 2.4.18, my DOCUMENT_ROOT is /var/www/html and for that directory AllowOverride includes FileInfo. Then I wrote :

CODE --> /var/www/html/.htaccess

RewriteEngine on
RewriteBase "/"
RewriteRule "(.+);(.*)" "$1?$2" [R] 
( Note : RewriteBase needed only because I put the rule in .htaccess; [R] added to redirect instead of rewrite. )

CODE --> /var/www/html/myAction.php

    '$_SERVER' => array_intersect_key($_SERVER, array_flip(['REQUEST_URI', 'SCRIPT_NAME'])),
    '$_GET' => $_GET,
( Note : I use PHP here, but that should make no difference. )

In the browser's location bar I type http://localhost/myAction.php;id=714&showAllSites=true?null

The browser redirects to http://localhost/myAction.php?id=714&showAllSites=true and displays :

CODE --> myAction.php's output

    [$_SERVER] => Array
            [REQUEST_URI] => /myAction.php?id=714&showAllSites=true
            [SCRIPT_NAME] => /myAction.php

    [$_GET] => Array
            [id] => 714
            [showAllSites] => true

While in the log it writes :

CODE --> /var/log/apache2/access.log ( fragment ) - - [10/Jan/2017:09:03:02 +0000] "GET /myAction.php;id=714&showAllSites=true?null HTTP/1.1" 302 596 - - [10/Jan/2017:09:03:02 +0000] "GET /myAction.php?id=714&showAllSites=true HTTP/1.1" 200 412 


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close