prakash Posted December 8, 2007 Share Posted December 8, 2007 Hi, I need to have rewrite rule for http://www.mydomain.com/whois.php?query=msn.com to http://www.mydomain.com/msn.com and the whois.php file must get the value of $query how can I do it??? Quote Link to comment Share on other sites More sharing options...
hackerkts Posted December 12, 2007 Share Posted December 12, 2007 Try this, RewriteEngine On RewriteRule ^(.*)$ whois.php?query=$1 To get the value of $query just use $_GET['query']. Quote Link to comment Share on other sites More sharing options...
prakash Posted December 12, 2007 Author Share Posted December 12, 2007 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] Quote Link to comment Share on other sites More sharing options...
prakash Posted December 14, 2007 Author Share Posted December 14, 2007 is there anyone who can help me?? Quote Link to comment Share on other sites More sharing options...
madmax Posted January 8, 2008 Share Posted January 8, 2008 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. Quote Link to comment 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.