Jump to content

Recommended Posts

Try this,

RewriteEngine On
RewriteRule ^(.*)$ whois.php?query=$1

 

To get the value of $query just use $_GET['query'].

 

on whois.php?query=somedomain.com

$_GET['query'] displays whois.php instead of somedomain.com

 

any help

 

please note that I have already following code on my .htaccess

Options All -Indexes

RewriteEngine on

RewriteCond %{HTTP_HOST} ^domain\.com [nc]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^/?(.*)$ /index.php [L]

  • 4 weeks later...

Your question isn't clearly stated. From your example you are obviously redirecting to a local file or directory based on the query parameter but you say the PHP file needs the query value also. Is this *really* true or are you just assuming this is the way redirection works? In other words, are you doing something specific using PHP with the query value??

 

If not then you don't need to use PHP at all for the redirection. Even if you use PHP locally in the target folder it doesn't need to be involved at the stage of redirection - this can all be done with mod_rewrite

 

If my assumptions above are correct then you can redirect using a *folder* target with query parameters and omit the WHOIS.PHP file altogether...

 

http://www.mydomain.com/whois/?query=msn.com 

 

From this you can either redirect or rewrite in the background. Redirection is clearer for the user as they will see the correct target folder updated in the URL bar of their browser. Background rewriting will pick up the correct content from an alternate/specific location but they won't see that location updated in their browser and this could cause confusion.

 

You can have a local/specific index.php to do "stuff" for each target query value - for example (dummy physical folder path) - /wwwroot/whois/msn.com/index.php 

 

However, *IF* the rest of your site design is dependent on the WHOIS.PHP to do other "stuff" then a different answer would be needed. Indeed, it would probaby be easier to use WHOIS.PHP to do "PHP header() redirection"

See http://uk2.php.net/header. This would be clearer to the user.

 

e.g.

<?
header("Location: http://www.yoursite.com/whois/msn.com");
exit;
?>

 

I think you'd need to say a bit more about what you want to achieve here to get the correct rewrite rule.

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.