Welcome to WebmasterWorld Guest from 54.167.155.147

Forum Moderators: Ocean10000 & incrediBILL & phranque

Message Too Old, No Replies

Rewrite Rule - Help Needed

   
12:23 pm on Oct 15, 2009 (gmt 0)

5+ Year Member



Hi,

I'm needing some help if possible in doing a .htaccess rewrite rule. I've not got a clue where to start or whether its even possible.

I've currently got vb advanced cmps installed in my domain root and vbulleting in a sub folder called /forum/

I'm wanting to remove cmps from the domain root and and set up a new cms system. Its going to take me a few days to do all this.

Is it possible to set up a rewrite rule so that I can from my IP address access the domain as normal but if anyone else tries to access a url in the root of the domain that are automatically forwarded to the forum sub directory. This would give me chance to change eveything over without having any downtime on my site.

Hope someone can help me with this or point me in the direction of where I can work our how to do it myself.

7:42 am on Oct 21, 2009 (gmt 0)

5+ Year Member



Can anyone help me with this?
9:58 am on Oct 21, 2009 (gmt 0)

5+ Year Member



wouldn't this be easier in php:

code:
<?php
if ($_SERVER['REMOTE_ADDR']!='##.##.##.##'){
header ('Location: [yoursub.domain.com');...]
}
?>

10:02 am on Oct 21, 2009 (gmt 0)

5+ Year Member



Also I'm too sure (I'm not an apache guru)

I dont know if apache has a variable for ip address built in that you could compare with a regex in your htaccess or configuration.

1:19 pm on Oct 21, 2009 (gmt 0)

WebmasterWorld Senior Member jdmorgan is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Conditions:
1) If not my own IP address
2) If request for root -- equivalently, if no subdirectory in URL-path, as determined by no slashes in URL-path

Action when conditions are met:
Redirect root requests to corresponding forum-subdirectory path.

---

With mod_rewrite:


RewriteCond %{REMOTE_ADDR} !=192.168.0.1
RewriteRule ^([^/]*)$ http://www.example.com/forum-subdirectory/$1 [R=301,L]

This code snippet assumes that you've already got other working mod_rewrite code, and therefore that you already have the required 'setup' directives at the top of your code to enable mod_rewrite execution.

Jim

5:51 pm on Oct 24, 2009 (gmt 0)

5+ Year Member



Thank you. Its just what I wanted and works perfectly.