PDA

View Full Version : .htaccess redirect while upgrading site.



davidpenney
08-13-2008, 05:55 PM
I need to redirect users from my current site to a sub directory while I implement the new website, whilst excluding my IP so that I can work on the new site.

The old site is Html based, and the new site is Wordpress based.

Any user that goes to the www.domain.com should be redirected to www.domain.com/old/
The same for any pages ie. www.doamin.com/page1.html >> www.domain.com/old/page1.html

This is to allow me to install and work upon the new wordpress install in the root.

I've found a lot of .htaccess examples which only divert the user to a single maintenance page, and I have had no luck trying to figure out how to do this. Any advice would be greatly appreciated.

thanks.

techietim
08-13-2008, 06:51 PM
Change 127.0.0.1 to your IP


RewriteEngine on
RewriteCond %{REMOTE_ADDR} !(127.0.0.1)
RewriteRule ^old/ - [L]
RewriteCond %{REMOTE_ADDR} !(127.0.0.1)
RewriteRule ^(.*) /old/$1 [R]

davidpenney
08-13-2008, 08:33 PM
thanks that works perfectly!

davidpenney
08-14-2008, 05:47 PM
After I have made some changes to the new wordpress install - which has updated the htaccess - visitors now gets the following error:

302 Found
The document has moved here.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Any suggestions?

the htaccess looks like this:

# Created by Redirection Module: Apache
# Wed, 13 Aug 2008 22:11:18 +0100
# Redirection 2.0.4 - http://urbangiraffe.com/plugins/redirection/

<Files .htaccess,.svn>
order allow,deny
deny from all
</Files>
Options +FollowSymlinks

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^weddingmobilebarhire\.co\.uk$ [NC]
RewriteRule ^(.*)$ http://www.weddingmobilebarhire.co.uk/$1 [R=301,L]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ (.*)index\.[php|htm|html](.*)\ HTTP/
RewriteRule ^(.*)index\.[php|html|htm](.*)$ $1$2 [R=301,NC,L]

</IfModule>

# End of Redirection
RewriteEngine on
RewriteCond %{REMOTE_ADDR} !(81.96.172.133)
RewriteRule ^site/ - [L]
RewriteCond %{REMOTE_ADDR} !(81.96.172.133)
RewriteRule ^(.*) /site/$1 [R]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

davidpenney
08-14-2008, 05:50 PM
without messing up any of the actual wordpress plugin settings etc? or should I just cut my losses, get the template finished, take down the orig and then build the new site up?

thanks.