Install a PHP Script in Subdirectory of WordPress: If you’re here, you probably want to learn how to install WordPress on your root domain and a PHP script on your subdomain. This is a great way to make maximum use of your domain and save money in the process.
It’s basically the process of installing a non-Wordpress script on a WordPress site. However, WordPress will interfere with a subdirectories PHP script. If this happens, you cannot access your non-Wordpress subdirectories, as WordPress overrides them with a 404 error. But not to worry – there’s any easy fix to this. Here’s how…
First, you’ll need to access the .htaccess file of your WordPress site. You can do this either through a FTP or File Manager in your cPanel. Remember that the .htaccess file is HIDDEN, so if you cannot unhide files in your File Manager, then FTP is the way to go.
We’ll focus on the FTP method, as you’ll most likely be using this.
Install a PHP Script in Subdirectory of WordPress:
- Login to your hosting’s cPanel and find your FTP settings. They normally connect directly to your root directory, but you can also create your own FTP connection directly to your chosen site – for easier access next time.
- Download FTP software – I normally use Cyberduck (Filezilla is also good).
- Open your FTP software, input your FTP details and connect to your website.
- In your menu, find the settings to “Show Hidden Files” and click it.
- Download the file named .htaccess (it’s normally right at the top of the list)
- Open the .htaccess file to make changes (I use Notepad++ for this)
- Now copy and paste the following text to the top of your .htaccess file: ErrorDocument 401 default
- Save your file and upload it again (ie. rewrite old .htacess file)
That’s it!
You have successfully installed a PHP script in a subdirectory of WordPress and it should be loading without any 404 errors.