Forum Moderators: phranque

Message Too Old, No Replies

(Website Link) IP Redirection

Newbie HELP needed asap

         

mcconvilletony

4:22 pm on Jul 27, 2008 (gmt 0)

10+ Year Member



My web server currently runs Apache 2.0. What I would like to do is to direct certain visitors to my website to slightly altered pages which have different content from what a standard visitor would see.
For example, if everyone clicks on the "WhatWeDo" button, they will be presented with the whatwedo.html page, however if a visitor is from a specific IP address, then I would like to transparently direct them to whatwedo2.html, which will have a slightly different version of the page content.
As I am new to Linux and all of this stuff I am having some problems. Is it correct that I need a .htaccess file to implement this?
I have been playing with the following .htaccess code:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_HOST} 1\.1\.1\.1 [OR]

RewriteCond %{REQUEST_URI} /sub_dir1/index/.html$
RewriteRule .* /sub_dir2/index.html [R=301,L]

Is this code even close to what I am trying to do?
Also can someone confirm for me how exactly to go about uploading a file from my Windows Documents folder to the Apache server as I am unsure of the code involved here.
I have read that the mod_rewrite module needs to be enabled to allow this using a .php file. I am pretty sure this is enabled however when I have tried accessing the link from various IPs I am getting various error messages (can't remember what they are right now).

Again I am new to all off this so any help would be greatly appreciated.

Thanks

Samizdata

8:15 pm on Jul 27, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to Webmasterworld!

Is it correct that I need a .htaccess file to implement this?

If you have your own server then no - but .htaccess may be more convenient.

can someone confirm for me how exactly to go about uploading a file from my Windows Documents folder

An .htaccess file is just a text file but because the filename starts with a dot it can be invisible on some systems. One way to deal with this is to name it "htaccess.txt" when creating it locally, then upload to the server with an FTP client and change the filename (depending on your FTP client you might also need to check a "show invisible files" option).

Is this code even close to what I am trying to do?

Some server setups will require Options overrides, others will not. I always leave them in.

# Set options
Options +FollowSymlinks +SymlinksIfOwnerMatch
# Turn on mod_rewrite
RewriteEngine On
# If the request is from a particular IP
RewriteCond %{REMOTE_ADDR} ^xx\.xx\.xx\.xx$ [OR]
# Or from another particular IP
RewriteCond %{REMOTE_ADDR} ^yy\.yy\.yy\.yy$
# Serve the alternate content
RewriteRule ^whatwedo\.html$ /whatwedo2.html [L]

Note that the last condition must not have an [OR] appended.

...

mcconvilletony

7:50 pm on Jul 28, 2008 (gmt 0)

10+ Year Member



Thanks for the speedy reply. Can you recommend a good FTP client? Thanksgain.

Samizdata

8:22 pm on Jul 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Can you recommend a good FTP client?

I recommend downloading any that are available and trying them out.

My personal favourite is Transmit for Mac OSX, which will be no use to you.

...

jdMorgan

12:35 am on Jul 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



FileZilla is a reputable open-source FTP client.

Jim

mcconvilletony

1:54 pm on Aug 18, 2008 (gmt 0)

10+ Year Member



OK I am using the advice given and have created a .htaccess file with the correct code however it doesn't seem to be recognised. No matter how I change it, when I try to access the link I get the same result (takes me to correct page even when I code for some extreme redirection).

HELP?

Am I missing something? Is there a setting I need to change?

Thanks.

jdMorgan

2:18 pm on Aug 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To help move this thread along:
  • Where did you place your .htaccess file? What is its URL-path in your site?
  • What are the contents? (please post the relevant code)
  • What URL(s) did you test with?
  • Did you completely-flush your browser cache before testing to avoid seeing 'stale' cached results?
  • What OS is running on your server?

    It is always a possibility that your host does not allow mod_rewrite; Try putting an invalid (e.g. misspelled) directive such as "RewroteRule" in your code, and see if you get a server error. If not, then you won't be able to use mod_rewrite on that server, unless you have access to the server configuration files.

    Jim

  •