Install a PHP Script in Subdirectory of WordPress

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:

  1. 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.
  2. Download FTP software – I normally use Cyberduck (Filezilla is also good).
  3. Open your FTP software, input your FTP details and connect to your website.
  4. In your menu, find the settings to “Show Hidden Files” and click it.
  5. Download the file named .htaccess (it’s normally right at the top of the list)
  6. Open the .htaccess file to make changes (I use Notepad++ for this)
  7. Now copy and paste the following text to the top of your .htaccess file: ErrorDocument 401 default
  8. 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.

Author

  • sherwinc

    Hey there! I've been blogging for over ten years now and have had the pleasure of writing for several websites. I've also sold thousands of books and run a successful digital sales business. Writing's my passion, and I love connecting with readers through stories that resonate. Looking forward to sharing more with you!

    View all posts