homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Rewrite Rule - Help Needed

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


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)

Can anyone help me with this?


 9:58 am on Oct 21, 2009 (gmt 0)

wouldn't this be easier in php:

if ($_SERVER['REMOTE_ADDR']!='##.##.##.##'){
header ('Location: [yoursub.domain.com');...]


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

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)

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} !=
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.



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

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

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved