Jump to content

Remote_host In .htaccess


alexfung
 Share

Recommended Posts

An example from Apache URL rewrite guide:

 

RewriteCond %{REMOTE_HOST} ^badhost\.mydomain\.com$

RewriteRule !^http://[^/.]\.****.* - [F]

 

Nevermind what exactly it is doing. At least it can detect the hostname of the requester. I can't get it work. %{REMOTE_HOST} is always null.

 

Similary PHP $_SERVER['REMOTE_HOST'] is null.

 

In php I can revert to gethostbyaddr($_SERVER['REMOTE_ADDR'], what do I do in RewriteCond?

 

By the way, can I access the rewrite log to ease debugging?

Link to comment
Share on other sites

Hi,

 

Without knowing exactley the end point your trying to achieve, I am not sure what you want from Remote_Host. The [F] Implies your trying to forbid a user though.

 

Its not possible to access the Rewrite log. Sorry

 

Jim

Edited by Jimuni
Link to comment
Share on other sites

The [F] just happen to be in the manual example. I wanted to serve some JS files depending on country, and doesn't what to add .js to the list of php processed extensions.

 

So my intention is:

 

RewriteCond %{REMOTE_HOST} ^.*\.hk$

RewriteRule (.*)\.js hk$1.js [L]

 

I quoted the example from the manual just to make sure I don't complicate the issue by making other mistakes unrelated to my inability to access the %{REMOTE_HOST}

Link to comment
Share on other sites

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.   Paste as plain text instead

  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.

 Share

×
×
  • Create New...