Client added a WordPress install to their document root directory. Afterwards one non-WordPress directory is giving a 404.
In a browser you can access /foo/facebook/index.php with no issues but you get the WordPress 404 page if you try to access /foo_admin/index.php. Wordpress is in / (not pictured here due to clutter).
Here is the entire .htaccess for the doc root directory:
# 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
EDIT:
Just realized a basic auth .htaccess in /gcb_admin is interfering somehow. Have now tried adding RewriteEngine off both before and after the basic auth directives but this changes nothing. Removing basic auth directives allows access to file...
AuthUserFile /home/foof/.htpasswd
AuthName "FOO Admin"
AuthType Basic
<Limit GET>
require valid-user
</Limit>
RewriteEngine off
How do I correct this?
Try this solution - essentially, it just turns off the rewrite engine in that specific directory:
http://wordpress.org/support/topic/exclude-directories-from-wp-rewrite
Add a .htaccess file to the directory that you want the Wordpress rewrite to ignore, with this code:
RewriteEngine off
Or, try changing the last line you have to:
RewriteRule ./ /index.php [L]
Related
First, I am sorry if there are similar threads, but I cannot figure out what is the right approach for the following problem:
I cannot figure out, how to properly change my .htaccess files, so that the following conditions will work:
I have 2 independent WordPress instances under one domain. (Lets say: example.com)
Old instance is hosted here: example.com/old/
New instance is hosted here: example.com/new/
Current behaviour when i access example.com:
When I access example.com, it redirects to the old instance.
Browser is showing: example.com/old
Desired behaviour, when i access example.com:
It Redirects to example.com/new/
Hides the subfolder path (/new) from the url, so that in the address bar only example.com is visible (or any other part except the /new/) in the middle.
My first approach was to add the following line in the /old/.htaccess:
Redirect 301 / https://example.com/new/
But then, it redirected example.com to: example.com/new/old/ which resulted in a 404.
Since the .htaccess files look kind of identical in /old/ and /new/ I cannot figure out, where exactly is defined, that example.com/ is redirecting to /old/ by default.
Here are the .htaccess contents of each instance and root folder:
.htaccess-content / (root)
# -FrontPage-
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
.htaccess-content /old/ (old instance)
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/
RewriteRule .* - [CO=wordpress_test_cookie:WP+Cookie+check:%{HTTP_HOST}:1440:/]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /old/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /old/index.php [L]
</IfModule>
# END WordPress
.htaccess-content /new/ (new instance)
#BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /new/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /new/index.php [L]
</IfModule>
# END WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301,NE]
Header always set Content-Security-Policy "upgrade-insecure-requests;"
</IfModule>
Any help is highly appreciated.
Thank you.
You need to use a RewriteRule in your old/. htaccess instead of using Redirect . A RewriteRule can map the request from your old directory to the new directory without a change in URL.
RewriteEngine On
RewriteCond %{REQUEST_URI} !/new [NC]
RewriteRule ^(.*)$ /new/$1 [L]
This should go in htaccess in your /root directory and remember to put this at the top or before other rewriting directives.
Also change "WordPress home URL" and "Site address" by going to settings->general in your WordPress dashboard.
You can use https://example.com as the WordPress home URL and https://example.com/new as your WordPress site address.
Let me know how it works for you.
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
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
I have researched this and unfortunately all I can find is general advice on htacesss and pass wording or general htaccess to redirect etc. None of them are what I am after here.
To sum up, we run a set of blogs all using the WordPress Multisite functionality.
All these files etc and info in the database are referenced by an ID and as such the site does not live in a folder.
I want to restrict one folder with a htaccess that our company uses to allow access to its users.
Normally I would drop that file in the folder and job done.
However, as mentioned there are no physical folders and so I need to somehow add this to the existing htaccess file that WordPress uses to handle everything.
Here is the htaccess file as standard:
RewriteEngine On
RewriteBase /
#uploaded files
RewriteRule ^(.*/)?files/$ index.php [L]
RewriteCond %{REQUEST_URI} !.*wp-content/plugins.*
# deperectaed after upgrade to v. 3.0 RewriteRule ^(.*/)?files/(.*) wp-content/blogs.php?file=$2 [L]
RewriteRule ^(.*/)?files/(.*) wp-includes/ms-files.php?file=$2 [L]
# add a trailing slash to /wp-admin
RewriteCond %{REQUEST_URI} ^.*/wp-admin$
RewriteRule ^(.+)$ $1/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule . - [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-.*) $2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
RewriteRule . index.php [L]
<IfModule mod_security.c>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
</Files>
</IfModule>
What I need to add is the following:
AuthName "You must be a valid user"
AuthType Basic
require valid-user
But I only need it to work on one site, say site id=2 for now. I would possibly like to add sites to this later.
Any help will be greatly appreciated.
Cheers
You can use the filesMatch directive to protect the directories. For a site at the path of /foo/ the following should work:
<filesMatch "^foo.*">
AuthName "You must be a valid user"
AuthType Basic
require valid-user
</filesMatch>
To Make sure the filesMatch directive works, try:
<filesMatch "^foo.*">
order allow,deny
deny from all
</filesMatch>
I installed the wordpress 2.9.2 a few days ago and it works correctly. today , i want to use permlink feature of wordpress.
I know , must modify my .htaccess file on my site root. but on my sub-domain root there is no any .htaccess file . so i create my .htacess file with follow content on sub-domain root (near index.php file):
<files .htaccess>
order allow,deny
deny from all
</files>
ServerSignature Off
<files wp-config.php>
order allow,deny
deny from all
</files>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Options All -Indexes
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
But after save it , i missed my blog . And i get follow error :
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.
after this i remove the .htaccess file , but this was not correct.
What i can do for it?
Cheers
I'm not sure what your other settings are there, but your rewrite block is correct. Try removing the rest of the contents of the file all together and see what happens. It may just be that you have more than you even need. Here is the entirety of my .htaccess for one of my WordPress installs with permalinks working correctly.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
- EDIT -
Also, that .htaccess is from a root domain that has sub-domains working accordingly without additional files or modification to the .htaccess.
Seems like a .htaccess file does not exist by default. But when you explicitly change the permalink structure by going to Settings->Permalinks in the WP admin area, a .htaccess file is automatically deleted. So, you may try to delete your current .htaccess file and then enable permalikns from admin area and .htaccess file will be automatically generated. First, my Wp install had no .htaccess file but when I altered the Permalink structure, here's what I got in my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I changed the .htaccess file with follow Content:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
But nothing happens and we have error again.
The amazing thing is: I removed the file, but the error is still there.