: 301 Redirect exception vs. Script new connection to DB 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
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:
.htaccess redirect exception for "olddomainname.com/login".
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
<IfModule mod_rewrite.c>
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
</IfModule>
<IfModule !mod_rewrite.c>
# 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
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
rewritecond %{REQUEST_URI} ^system.*
rewriterule ^(.*)$ /index.php?/ [L]
rewritecond %{REQUEST_URI} ^application.*
rewriterule ^(.*)$ /index.php?/ [L]
rewritecond %{REQUEST_FILENAME} !-f
rewritecond %{REQUEST_FILENAME} !-d
rewriterule ^(.*)$ index.php?/ [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!
More posts by @Samaraweera270
2 Comments
Sorted by latest first Latest Oldest Best
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 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 ^ 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)(/.*)?$.)
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.