subdomain .htaccess & htpasswd files affecting root directory - wordpress

I have built a site for a client using WordPress. The site was built on the subdomain http://staging.url.com. Using Plesk I restricted access to the 'staging site' using a password
When site was completed I downloaded 'staging site', duplicated the database and re-uploaded to http://www.url.com. Everything works ok apart from when I'm logged into the wordpress admin, I get the Authentication Required pop-up, saying http://staging.url.com requires a username and password.
I cannot find any file that would be telling the server that http://www.url.com is http://staging.url.com and prompting the Authentication Required pop-up.
Can anyone help?
Many thanks,
Elliott.
Current http://staging.url.com htaccess file
# 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
AuthType Basic
AuthName "restricted area"
AuthUserFile /var/www/your-url/.htpasswd
require valid-user
Current http://www.url.com htaccess file
# 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

I think your files it is loading from your staging website
Go to inspector on your browser and check if any image or files are loading from your staging in the production website.

Related

wordpress wp-content/uploads folder 301 redirect to S3 bucket by cloudfrond CDN by .htaccess issues

See below, the .htacess file from Wordpress. If I remove the part starting from # BEGIN WordPress, all the image file URLs will be changed to d28rt1vkpsdxas.cloudfront.net/someimage.png successfully.
However, all the internal links will be unable to access (only the home page can access). The error is
Not Found The requested URL /shop/ was not found on this server.
But if I keep the part start from # BEGIN WordPress, the CDN redirect will not work anymore. All photos are missing.
Options +FollowSymlinks
RewriteEngine on
Rewriterule ^wp-content/uploads/(.*)$ http://exampled28t1vkps.cloudfront.net/$1 [r=301,nc]
# 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
You’re missing the [L] flag, which prevents other rules from redirecting:
Rewriterule ^wp-content/uploads/(.*)$ http://exampled28t1vkps.cloudfront.net/$1 [r=301,nc,l]

Wordpress site in subfolder of another wordpress site .htaccess issue

I have a wordpress site in a folder
/site1
That site is site1.com
I have another wordpress site (totally separate install) in a subfolder of that site
/site1/site2
That site is site2.com
Ideally I would like to be able to access this site by typing either of these two things...
site1.com/site2
or
site2.com
So far, that works. However, I can't do something that's really important.
I can't type, say
site2.com/forums and get to my forums. I get an internal server error. The only way to get to the forums is to go all the way back to site1.com/site2/forums
Can someone tell me what needs to change in my .htacces, wp-config, or wordpress dashboard to make this happen (and in what subfolder to make these changes?)
.htaccess for site1
# 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
<Files 403.shtml>
order allow,deny
allow from all
</Files>
.htaccess for site2
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /site2/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site2/index.php [L]
</IfModule>
# END WordPress
As stated in the comments, both the wp url and site url are http://site1.com/site2 as doing anything else broke the sites.

wordpress site ignoring sub directory when htaccess present

To begin I did not setup the website I am currently working on, and I am not very familiar with the wordpress setups. I have been called in on their site to add an admin section to this site which uses a Wordpress configuration. If I add a sub-directory, I can access the sub-dir via web just fine. The problem comes when I add a .htaccess to that subdirectory for Auth purposes. When I do this, and try to access the sub-directory, it errors to a 'Page Not Found'.
Can someone please help? I assume it is something with the Wordpress .htaccess file provided below:
# 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
UPDATE
When the .htaccess in the sub directory is blank, I can access the sub-directory via web just fine.
.htaccess (when filled out) in sub directory is below:
AuthType Basic
AuthName "Sphere"
AuthUserFile "/path/to/htpasswd"
require valid-user
I just tested a setup based off of your question. Here's an example of the hierarchy from what I could gather in your post:
public_html/ (all WP install files here)
public_html/admin/ (here I created a new folder similar to your question)
public_html/admin/index.php (test file - just echos a line of text)
public_html/admin/.htaccess (currently blank)
So my .htaccess within the new subdir that's spawned off of the WP root is blank. I'm not sure what kind of auth things would/should be in there. If I access "website/admin/" - the test line echos just fine. I don't see any 404s.
Could you maybe provide a little more detail so I can try to better replicate the issue you're seeing?
Found the solution for my problem elsewhere. Editing the root .htaccess (for wordpress) to match the one below should fix anyone who also encounters this issue:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/NameOf_Directory_ToAllow/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/NameOf_AdditionalDirectory_ToAllow/(.*)$ [OR]
RewriteRule ^.*$ - [L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

.htpasswd in subfolder on Wordpress Install

I have a wordpress install at the root of my home folder, and I have a subfolder that I am trying to protect with an .htaccess based login. In the root there is an .htaccess with these rules:
# 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
Then in my subfolder I have this .htaccess
<IfModule mod_rewrite.c>
RewriteEngine off
</IfModule>
AuthName "MySQLDumper"
AuthType Basic
AuthUserFile "/home/freegame/public_html/msdump/.htpasswd"
require valid-user
With the Wordpress rules active, access the subfolder causes a 404 error. When I delete the wordpress rules, it works fine. Any ideas on what I've done wrong?
Your method will work only for files. For protecting directory you have to perform an additional step. Modify the htaccess file in the your site’s root directory and add the following above the #Begin WordPress comment.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(failed_auth\.html).*$ [NC]
RewriteRule . - [L]
</IfModule>
This will stop WordPress from giving a 404 error code when you try to access your password protected directory. Instead it will give a 403 (authorization required) and prompt you for a valid username/password instead to access it.
Source: Dreamhost

.htaccess Do Not Redirect For My IP

I am doing some changes directly to the server on my Wordpress website. I've modified the access file and I want all the users to be redirected excluding my IP. So basicly when I access the website I want it to work normally but when someone else access it I want it to be redirected to a maintenance page.
Here is my current .htaccess file which doesn't work:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REMOTE_ADDR} !^89.137.131.186
RewriteCond %{REQUEST_URI} !^/maintenance/index\.php$
RewriteRule ^(.*)$ http://domain.com/maintenance/index.php [R=307,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Why use a redirect? Why not use this plugin: http://wordpress.org/extend/plugins/ultimate-maintenance-mode/
It's what I use for Maintenance pages. All user's who have logged in will be able to see the site as normal. All non-logged in users will see the maintenance screen which is customizable.

Resources