I'll get right to it because this will be long.

I've built a WordPress site for a client on a new domain name and 301 redirected his 3 other domains to point to it. Then, I learn that he has a database associated with his site that his clients need to access. I had not noticed this, but it is there.

Logging into the database was accomplished by going to 'olddomainname.com/login'. Problem is, now with the redirect in place I can't get there. Solutions from GoDaddy support were:

  1. .htaccess redirect exception for 'olddomainname.com/login'.
  2. Script a new connection to the database (since DB isn't bound to domain).

I am, of course, in over my head here! I've never worked with DB's and though I can follow instructions I fear messing with scripting a new connection because it seems complicated (multiple users etc).

I'd love to add the redirect exception for 'olddomainname.com/login' because it seems like the simplest option. I have googled plenty for answers and tried a few things but without success. Also, would the exception have to include whichever directory I'm taken to next after login?

I'll post the .htaccess file below and hopefully you all can point me in the right direction. It is rather long,, also I have Ultimate Coming Soon Page plugin installed so I don't know if that's messing with the few exception attempts I've made, though I can see the site when I'm logged in just fine.

rewriteengine on rewritecond %{HTTP_HOST} ^www.olddomainname.info$ [OR] rewritecond %{HTTP_HOST} ^olddomainname.info$ rewriterule ^ 'http\:\/\/newdomainname\.com\/' [R=301,L] #4f8bdeef8097b rewritecond %{HTTP_HOST} ^www.olddomainname.biz$ [OR] rewritecond %{HTTP_HOST} ^olddomainname.biz$ rewriterule ^ 'http\:\/\/newdomainname\.com' [R=301,L] #4f8bded088493 rewritecond %{HTTP_HOST} ^www.olddomainname.com$ [OR] rewritecond %{HTTP_HOST} ^olddomainname.com$ rewriterule ^ 'http\:\/\/newdomainname\.com' [R=301,L] #4f8bde0b68ea5 rewritecond %{HTTP_HOST} ^www.olddomainname.net$ [OR] rewritecond %{HTTP_HOST} ^olddomainname.net$ rewriterule ^ 'http\:\/\newdomainname\.com' [R=301,L] #4f8bdea67d365  RewriteBase / #Removes access to the system folder by users. #Additionally this will allow you to create a System.php controller, #previously this would not have been possible. #'system' can be replaced if you have renamed your system folder. #When your application folder isn't in the system folder #This snippet prevents user access to the application folder #Submitted by: Admin1 #Rename 'application' to your applications folder name. #Checks to see if the user is attempting to access a valid file, #such as an image or css document, if this isn't true it sends the #request to index.php   # If we don't have mod_rewrite installed, all 404's # can be sent to index.php, and everything works as normal. # Submitted by: Admin2 ErrorDocument 404 /index.php  # BEGIN WordPress  RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]  # END WordPress # BEGIN WordPress  RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]  # END WordPress # BEGIN WordPress  RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L]  # END WordPress rewritecond %{REQUEST_URI} ^system.* rewriterule ^(.*)$ /index.php?/$1 [L] rewritecond %{REQUEST_URI} ^application.* rewriterule ^(.*)$ /index.php?/$1 [L] rewritecond %{REQUEST_FILENAME} !-f rewritecond %{REQUEST_FILENAME} !-d rewriterule ^(.*)$ index.php?/$1 [L] rewriterule ^index\.php$ - [L] rewritecond %{REQUEST_FILENAME} !-f rewritecond %{REQUEST_FILENAME} !-d rewriterule . /index.php [L] 

That's it. Sorry there's so much but I wanted to make sure you had all the info in case something else in the file was interfering. Only other stuff in there is the gzip stuff and I left that out. Any help is much, much, MUCH appreciated as this is for a client and I'm feeling, well, down in the dumps about the spot I'm in.

*Mods: I see my post is quite long compared to others I've seen. If I'm too long-winded or off in any way with this first post of mine please let me know!

  • Try adding this: RewriteCond %{REQUEST_URI} !^/login
  • Thanks for the reply ionFish. Yes, I tried this line with no success. I tried moving its position in the redirects at the top of the file and did also empty my browser cache. It did not work, any idea why?

How is the database accessed by the clients?

Have you tried setting up a sub-domain pointed directly to the database? If the subdomain never goes near your document root it should be unaffected by the htaccess commands.

  • Hi toomanyairmiles, thanks for your reply. I understand your workaround and it seems like a great idea. However, as stated in my comment to Ilmari's answer where I go into some detail, I feel my only option at this point is to script a new connection to the DB, as the original site was apparently overwritten when I installed WP, which has never happened in the past. bows head in shame I'm looking for tutorials on scripting a new connection to the DB, failing that I'll seek the professional aid of someone who can, perhaps the original webmaster who created the DB. Thanks so much my friend.
  • @SteveOWD when you say it overwrote the old site what exactly do you mean, can you be more specific?
  • Sure toomanyairmiles. In the past (hostgator) I've installed WP on an additional add-on domain, a .net for example. This domain has its own folder (newdomain.net) in the root. In this case none of the domains have their own folders in the root so I feel when I installed WP, despite the fact I wanted to attatch it to the .net, because the .com is the primary domain it was installed there (wp-admin, content etc are now in root). When installing WP it warns 'Installing WP may overwrite existing files'. I cannot locate the files associated with the old site so,, this may have happened?
  • 1 @SteveOWD it would have overwritten files with the same name, but it's unlikely it would have wiped out the whole site. Are there no backups?
  • I'm not the webmaster for the original site (evidenced by cluelesness), I'm looking for the backups now. I have been able to locate some of the .jpg/.png files associated with the site so you may be right. I'm going to remove the redirect temporarily and see if that helps me figure out what's going on. I recognize I'm out of my comfort zone and since this is for a client there's only so many attempts I'm willing try out before seeking the aid of someone who I can pay to do this (i.e. original webmaster, hopefully). Thanks SO much for your guidance.

To be honest, it looks a lot like you were in over your head even before any databases entered the picture. For the sake of the client, though, here's some code that should work (when placed in an .htaccess file at the site's www root directory):

Options +FollowSymLinks RewriteEngine On RewriteBase / # Do not apply any later rules to http://olddomainname.com/login: RewriteCond %{HTTP_HOST} ^(www\.)?olddomainname\.com$ [NC] RewriteRule ^login(/.*)?$ - [L] # This does the same as your existing rewrite rules, just simpler: RewriteCond %{HTTP_HOST} !^newdomainname\.com$ [NC] RewriteRule ^ http://newdomainname.com/ [R=301,L,NS] 

What you really should do, though, is read the mod_rewrite documentation carefully until you understand exactly what this code does.

(I should also note that I haven't actually tested this code. It looks good to me, but for all I know, it might have some silly typo or something that makes it fail to work.)

Ps. Unless the database interface really is entirely located under the /login directory, you'll probably have to add some more exceptions. The easiest way to do that is by editing the regexp in the first RewriteRule to something like ^(login|database|whatever)(/.*)?$.)

  • Hi Ilmari, thanks for the reply. I'll take your criticism as I do deserve it in this case, I am 'green' in this field, as I'm about to prove even further. I tried your solution with no avail, I have a feeling I know what the problem is. When I installed WP temporarily on the .net domain, I feel it may have overwritten the original .com site (huge facepalm). In the past this did not happen but in this case it seems it has. Meaning these redirects will not work if the page I'm trying to point to is gone. Scripting a new connection to the DB seems like my only option. Tutorial time. Thanks again.
  • Oh dear. In that case, I do hope you have backups...
  • I did not build the original site, I've taken over the job from someone else. I'm looking for backups now. I'll probably end up seeking the help of the original webmaster. Thanks so much for taking the time to help me out, if I had higher reputation I would mark your answer as 'useful' but alas.. Best regards, Steve
  • Thanks Ilmari, I'd like to give you both the accepted answers but I feel I should give it to toomanyairmiles because he provided more replies. Thanks SO much for your help!

Pracoval pro vás: Charles Robertson | Chcete nás kontaktovat?

užitečné informace