htpasswd on wordpress - wordpress

Im trying to develop a web page based on wordpress, i have done many localy, but want try make the production on the cloud, but want close page access with .htpasswd.
I read a lot of articles, and im follow this steps:
Insatlling wordpress..etc
At point 2, i tried few things:
Create a manually .htacces on the root and put:
<Files .htaccess>
order allow,deny
deny from all
</Files>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/directoryname1/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/directoryname2/(.*)$ [OR]
RewriteCond %{REQUEST_URI} ^/failed_auth.html$
RewriteRule ^.*$ - [L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
AuthName "Texto al gusto"
AuthUserFile /test/.htpasswd
AuthType basic
Require valid-user
Or use some plugins for edit htacces because maybe i was deleting some line uploading mine.
Im triyed deleting some parragrahps on the htacces, the wordpress because i dont have permalinks active, and others.
I put the htpasswd on the test folder and all correct.
I actualize my webpage and appear the popup of the htacces, i put the user and pass and then...always appear this...
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webadmin#kundenserver.de and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Related

Synology Personal Websites htaccess results in 403 errors

Synology Server with DSM 7.1.x (recently updated from DSM 6.x and downgrading back down to DSM 6.x is not recommended by Synology)
Webstation Enabled with HTTP back-end server: Apache HTTP Server 2.4 and PHP:
PHP 8.0
Personal Websites with these settings HTTP back-end server: Apache HTTP Server 2.4 and
PHP: PHP 7.4
Personal Websites use WordPress 5.x or 6.x which require a .htaccess file
Problem: Personal Website .htaccess in /homes/user/www folders causes the 403 error
Could delete .htaccess to stop 403 error but Personal Websites use WordPress which requires .htaccess - cannot just delete this file because some WordPress actions recreates the .htaccess file (such as changing Settings > Permalinks)
Newly created test user case: tmp
homes/tmp/www folder has "users" group with 775 permissions
homes/tmp/www/.htaccess has owner of "username" and group of "users" with 770 permissions
homes/tmp/www/wp-config.php has owner of "username" and group of "users" with 770 permissions
Even with permissions of 777 for ALL files in homes/tmp/www, the 403 error still exists with .htaccess
After deleting the .htaccess and creating/publishing a new page, viewing the new page results in a 404 error.
Default .htaccess lines
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /~username/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~username/index.php [L]
</IfModule>
Even if .htaccess has no lines of code at all, the 403 error exists. So just the existence of the .htaccess file regardless of content causes a 403 error.
Anyone have ideas to solve this problem?
Solution I stumbled upon:
Edit the httpd2x.conf for Apache2.x (whichever is chosen for Personal Websites)
Add the following code
UserDir www
<Directory "var/services/homes/*/www">
Options FollowSymLinks
AllowOverride All
</Directory>
I tried a bunch of stuff and I think the above was the trick.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /~username/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~username/index.php [L]
</IfModule>
It looks like you are using Apache per-user web directories? If that's the case then /~username is not a physical directory (it's an "alias" to your user directory) and your document root is effectively /~username/ (which really messes with root-relative URL-paths).
In which case, your .htaccess should be like this instead:
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
Note that I've removed the RewriteBase directive altogether.
However, if this is part of the WordPress code block (ie. inside # BEGIN WordPress ... # END WordPress) comment markers then WordPress is going to try and overwrite your changes unless you take additional steps to prevent this.

no permission on wp_admin

I installed the latest version of wordpress in my hosting server. How ever I was not able to add any media. I checked the server space and I have still of huge free space. And then I try to access settings --> media , I got this error
You don't have permission to access /wp-admin/ on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
I added the this into my .htaccess file but still no luck
# BEGIN WordPress
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
<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
Any ideas?
-Alan-
You must download Filezilla and put permissions 755 on every WP file inside your hosting. Also, if this don't work, try to remove all plugins, maybe some plugin is causing the problem.

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

Possible permalink or .htaccess error, wordpress

Okay. So I have a site that needs to be live around 8am EST. Everything was going fine, but when I uploaded it to the server my two pages return 404 not found errors. Absolutely everything else on the site is fine.
I have tried several things. I have reset the permalinks several times. I have deleted auto-saved files in the database. I have re-uploaded the database. I have re-uploaded the site. I have set the permission on .htaccess. I have deleted .htaccess and let it rewrite itself. Nothing has worked. Does anyone have any ideas?
The page works when it is set to default, but NOT when it is set to anything else.
Update This is the .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
Based on the .htaccess you can make these changes... although this is the default .htaccess for Wordpress it looks like it has an extra slash in front of index.php for the main redirect line. You'll also want to check to make sure that your Virtual Host Apache directory contains AllowOverride All.
In this example we're telling Apache if the request isn't for index.php then see if it's a real file and a real directory, then if it's not show them the default page. This is similar to the default behavior of Wordpress already.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !=index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* index.php [L]
</IfModule>
# END WordPress
There is also a whole Stack Exchange site devoted to Wordpress at wordpress.stackexchange.com.
This is basically the same question:
https://wordpress.stackexchange.com/questions/11149/htaccess-disable-wordpress-rewrite-rules-for-folder-and-its-contents

404 due to WordPress mod_rewrite rule?

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]

Resources