I have duplicated my site using the duplicator plugin from wordpress.org. However, when I wanted to run this on a new hosting service, first I encountered a 504 gateway timeout error. Therefore, I extracted the .zip contents and chose for manual package extraction, which solved the problem, but after the second step, again in the final step (test), I run into a 403 access denied error.
I checked my access permissions, they were OK. (755 for folders and 644 or 666 for files)
I checked my .htaccess file, it seemed to be OK. (I deleted it and the error appeared again).
There are no plugins on my domain or host which might cause interference as I am installing the package afresh.
I don't know what is causing this problem.
My .htaccess file contents:
# 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
403 Forbidden error code is shown when your server permissions don’t allow access to a specific page.
Another possible cause could be a corrupt .htaccess file or incorrect file permissions on your server.
If you were already using an automatic WordPress backup plugin, then make sure that you have access to the latest backup before moving forward.
Deactivate all WordPress plugins
First thing you need to do is to temporarily deactivate all WordPress
plugins. This includes any security plugins that you may have installed on your site.
If this resolves your problem, then this means one of the plugins on
your website was causing this error.
You can figure out which plugin was causing the error by activating
all your plugins one at a time until you are able to reproduce the
403 forbidden error.
Corrupt .htaccess File
Often the 403 error is caused by a corrupt .htaccess file in your WordPress site. Repairing this file is quite easy.
You need to delete the file from your server. (get backup file)
Try accessing your website. If 403 forbidden error is resolved, then this means that your .htaccess file was corrupt.
You can generate a fresh .htaccess file by logging into your WordPress admin area and going to Settings » Permalinks page.
Simply click on the Save Changes button at the bottom of the page and WordPress will generate a fresh .htaccess file.
File Permissions in WordPress
All folders on your WordPress site should have a file permission of
744 or 755.
All files on your WordPress site should have a file permission of 644
or 640.
You can set the file permission to the root folder to 744 or 755.
Check the box next to ‘Recurse into subdirectories’ and then check
the option that says ‘apply to directories only’.
I hope this helped you fix the 403 forbidden error in WordPress
This is old but I would like to post something I'm about to try. I found that "open_basedir" may be enabled by default on some hosts, like the one I'm using. So I sent a request to the provider to disable it from "php.ini" file.
Related
I've been having some issues with my wordpress theme, i recently created a new theme and tried using it in my wordpress site, but i discovered that the css isn't loading. The css loads properly in my localhost and i didn't make any changes before uploading to the server,but after i uploaded it to the server, my css stopped working. I've never experienced this before and I'm 100% sure my header.php and functions.php file are correct. I checked with chrome dev tools to see if my css is loading, and it loads correctly.
I can see my css files showing in the head section in chrome dev tools, but my website page isn't displaying with the styles. Please what do I do? Also, i used wordpress 5.4.2 in my online server, but i used wordpress 5.3.4 in my local machine, does this affect anything
Looking at your website, your css files are all 404s. So the issue appears to be your server and not in WordPress. Please ssh/ftp/etc into your server and verify the files exist and have the correct permissions and ownership. In other words, could be a number of things wrong with your server, but the first things to look at are:
Do the files exist on the server in the correct location?
Do the files have 644 permissions?
Do the files have the correct owner? (I.e. if you uploaded as root, root owner should be the owner of the new files. Works fine if the files already existed, uploading as root (typically) won't change this, but if they're new they'll default to the logged in user).
Check your .htaccess, remove folders and just have index.php inside of it.
By folders I mean if it says eg. /new/index.php, just leave /index.php, and also check rewrite base.
You should have something like this
# BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
You should also check your urls in wp_options in database.
If it says http://localhost/your-project/ then you need to replace it with your current url of the project that is remote.
I think you need to flash your permalink. Just go to setting>permalinks and hit save button. I hope your css file will work fine after flush your permalink.
Thanks
In my web-app that is written in php and using Symfony v2.8, I have a contact page that when submitted to the server creates two emails that should include a graphic, but when this graphic is actually included I get the following error:
Unable to open file for reading
[https://fake.net/Resources/public/images/landing_page/mypic.png]
500 Internal Server Error - Swift_IoException
Stack Trace
in vendor/swiftmailer/swiftmailer/lib/classes/Swift/ByteStream/FileByteStream.php
at line 144 -
if (!isset($this->_reader)) {
$pointer = #fopen($this->_path, 'rb');
if (!$pointer) {
throw new Swift_IoException(
'Unable to open file for reading ['.$this->_path.']'
);
}
However, the problem isn't with the swiftmailer, because if I do not include the graphic, the emails are successfully created and sent. Alternatively, when the .htaccess, which I'm using to protect my site, is file renamed, the emails are again successfully created and sent when the graphic image included.
Today, while trying to fix this I found that the same graphic that is displayed in several pages of my web-app, is now unable to load when the .htaccess is in place. The error that I'm now getting is:
GET https://fake.net/Resources/public/images/landing_page/mypic.png
500 (Internal Server Error)
Here are the lines that I added to end of my .htaccess file:
# Allow access of the mypic logo for emails
<files mypic.png>
order allow,deny
allow from all
</files>
Before the above statement are the following line, which have always been in the .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
<If "%{HTTP_REFERER} != ''">
# Hot link prevention for css|gif}htm|html|jpg|js|mp3|mp4|php|png files
# from any other domain than %{HTTP_HOST}
# See http://tltech.com/info/referrer-htaccess/
RewriteCond %{HTTP_REFERER} !^.*$ [NC]
RewriteCond %{HTTP_HOST}##%{HTTP_REFERER} !^([^#]*)##https?://\1/.* [NC]
RewriteRule .*\.(css|gif}htm|html|jpg|js|mp3|mp4|php|png)$ - [NC,F]
</If>
</IfModule>
While, none of this limits file access to read-only, the file's permission being set to 664 does this. Is this something that .htaccess can do to force read-only access when the file's permission is 666?
The statement appears to grant access to any file with that name, not just to the one specific file I want to have unlimited read-only access, which is located in the web\Resources\public\images\landing_page directory. However, when I try using a relative or absolute path, the email creation still blows-up with the same error. Please, address this in whatever solution is suggested.
Obviously, the statement is causing the web-site's problem accessing the graphics. How do I properly override the .htaccess rule controlling access to this file in my emails?
I was told to move the file out of the area controlled by the .htaccess file, but my whole site is controlled by the .htaccess, so moving the graphic file to the directory above the site's web directory, would make the graphic file beyond the scope of my web-site, so also not available.
I have migrated a dynamic website (php, mysql) to a new host on a shared server plan.
The site is fully dynamic and has no fixed paths as such apart from the single entry point file "portal.php". The site exists as path-info to portal.php and is created from templates in a mysql database. There is no /portal directory, for example.
The homepage loads fine, but not subpages.The pathinfo is returned correctly, but the webserver is not translating it I guess:
http://example.com/portal/p/Logon = Fails with 404 error
http://example.com/portal.php/p/Logon = Works!
I have limited control over the apache server as the client has a basic, shared server plan.
I tried various options in a .htaccess file at the root of the website directory, but the best I could do was get an internal 500 error. At least I know the .htaccess is being read.
I'm hoping I can resolve this, otherwise I will have to migrate the site to a dedicated server instead.
Ok I found a solution. I see now why my initial post lacked information :)
I read this guide:
https://httpd.apache.org/docs/current/content-negotiation.html
And after trial and error, the following worked with a .htaccess file placed at root (I modified a html5boilerplate .htaccess file):
Options -Multiviews
RewriteEngine On
RewriteBase /
RewriteRule ^portal/(.*) /portal.php/$1
RewriteRule ^portal$ /portal.php
I am installing Yii2 on a shared hosting environment,Apache, (Godaddy),
here is what I did as per the docs:
Renamed web folder to www
copied all the folders, now the directory structure looks like this:
public_html\
assets
commands
config
controllers
model
modules
views
www\index.php
.htaccess (this is both in public_html and www)
but when I access my domain, I get the following error:
You don't have permission to access / on this server. Additionally, a
404 Not Found error was encountered while trying to use an
ErrorDocument to handle the request.
Here are the contents of my .htaccess which I have copied in both public_html and www.
Options +FollowSymLinks
IndexIgnore */*
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
is the htaccess creating problem? Is index.php not being run from the right folder? What else should I look for? any help is much appreciated.
Update:
The actual problem with the above error was that It was a Permissions issue.
Set the permissions from 644 to 755, and now the system is accessible.
BUT
the to access index.php I still need to navigate to it manually by typing in the url : www.example.com/www/index.php
UPDATE
As I don't have prettyurl's enabled, just to make it work, I deleted all the contents of the .htaccess, then I copied the contents of basic folder in the home folder (for future visitors it should be like home/your_user _name
CAVEAT EMPTOR
I know almost nothing about .htaccess. Also my this project is just for learning, this solution may not be useful in production settings.
Question is still open for expert advice on best practices in such scenario.
You need to move your domain pointer to www instead of htdocs, its probably somewhere under domain -> root folder. Your .htaccess looks fine.
I can't access any pages/login to my WordPress based website.
I get this message:
Forbidden You don't have permission to access / on this server.
after some research on StackOverflow and other WordPress support forums I tried to change the .htacess file without success, also tried to duplicate it from the root directory to /wp-admin again nothing has changed... But I'm not really sure about what I did...
I went back to how it was when it stopped working
permissions are 705 for the folder and 604 for the .htaccess file which is :
SetEnv PHP_VER 5_3
# 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'm using WP 3.4 and I don't know if I use PHP 5.3 (what says the .htaccess 1st line) or 4.0.1 (on PHPMyAdmin from the website host access 'OVH')
Thank you very much for your attention.
Ismaël
Make WP recreate the .htaccess the file itself.
Delete .htaccess via FTP, then change your permalink structure to default, then back to your desired permalink style. This will recreate the .htaccess. if that fails, you can try to reinstall the WP core by deleting everything except wp-content and wp-config.php.
Found this when looking for a similar issue I had. Cause & fix was different but may be useful to others...
I have some content external to the WordPress implementation, in a directory called "Documents" (outside the WordPress hierarchy). I then wanted a Wordpress page to list those documents so I called the page "Documents". Accessing that page gave an error. The fix was to rename the directory as "docs" (moving it to wp-content may have worked too).
If you are using WP All-in-One Security plugin, be sure to check the .htaccess file in the root of your Wordpress installation, and look for a section on whitelisted IP addresses. If your current IP is not in the list, then you will get the 403 error.