Forum Moderators: phranque
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
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.
...
HELP?
Am I missing something? Is there a setting I need to change?
Thanks.
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