Static PHP application directory on a wordpress site - wordpress

I'm having trouble setting up a directory with php files on a wordpress site.
I understand how to use templates to include a custom php file, but what I'm trying to do is access a php file as if wordpress was not installed. Right now when I create a new directory(dir1) and put an index.php file in that folder, then try to view by going to www.test.com/dir1 it shows a bulleted list with links to header, background, and updates with a text input for searching the website at the bottom.
I'm not sure if this is something that needs to be configure in my cPanel or if its a wordpress setting, or even if its an htaccess issue.
Please help me figure out what I need to do, or even at the very least, help me put into words what I'm trying to do. Thanks!

Usually Wordpress installed in the root has no impact at all on whatever is put into non-wp directories. Can you paste your .htaccess file from the root folder? And does your /dir1/ have any .htaccess?

Wordpress has nothing do to with existing folders/files. Here are some steps you may try.
Make sure your /dir1 doesn't have .htaccess or if in case you have and you need it to have it there, continue doing next steps.
Add some inclusions in rewrite engine of your .htaccess file. You may add something like this:
RewriteCond %{REQUEST_FILENAME} !-d and/or RewriteCond %{REQUEST_FILENAME} !-d
or
RewriteCond %{HTTP_HOST} !dir1
I hope this helps.

Bah, I've figured it out.
anytime I would FTP files onto my server, it would make the owner/group "root"
After I used WinSCP to change my users to match each website, it worked perfectly.
cPanel is a pain.

Related

After WordPress migration only home page loads everything else returns a 404

Getting started with a droplet on Digital Ocean, so far it's been a fun process. Now I want to begin migrating my site, so I set everything up and created an index.php to where to my root dir as a "construction" page for now. I'm setting up WordPress in a sub-dir and moved all of the contents via all-in-one WP Migration which has always worked perfectly for me.
I've given every dir and file inside of root/public_html (WordPress installation) rwx and atm ownership has been changed to www-data. So I got to loadup my site which atm would be something like <ip address>/public_html and I log in and I am propmted with the wp-admin screen. Everything is working, media files are uploaded, theme is there etc.
When I go to my home page, all the images load but I immediately notice the admin bar at the top, the wp-glyphs aren't loading and I'm getting those weird squares when your computer/phone doesn't know what it's trying to look at. Also any front-end page other than my home returns a 404. My homepage again is accessed by <ip address>/public_html so you would think my about page would be <ip address>/public_html/about, which is where WordPress is sending me to when clicked, but I receive a 404.
I've spent probably 4-5 hours now trying to figure this out and eventually turned to a guide that walks you through it but nada so far.
Can anyone offer a suggestion?
EDIT
I'd like to add that I followed WordPress's instructions on modifying the .htaccess file. I'm assuming it goes in the subdirectory correct?
.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /public_html/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /public_html/index.php [L]
</IfModule>
Just as a reference for myself and anyone who might stumble upon this.
Solution
The answer was that apache was not configured correctly to read .htaccess files. If you are experiencing the same problems and have set up your own VPS, go to apache.conf, etc/apache2/apache.conf and find the correct <Directory></Directory> directive that corresponds with your website directory. Inside you should see an option that reads AllowOverride None. Change this to AllowOverride All.
If this is not the solution for you, at least it's another step out of the way.
Are you able to access wp-admin
If yes then go to dashboard->setting->permalinks
and update the permalink and the problem solved
Access your dashboard by logging in wp-admin then access settings then permanent links, Change them to any of the provided styles save the change it again to your preferred one. This will work well.

Wordpress Install with other software installed in a subdirectory

I'm having an issue that I think can be solved with .htaccess, however, I'm not sure exactly how, htaccess rules have never been a strong point for me.
I have a domain with WHMCS installed on it, in a subdirectory, like this:
/websites/manage/
the /websites/ directory is otherwise empty.
Now, I have installed WordPress on the root of the domain, and I want to use the /websites/ location in the WordPress permalink structure, as I want to build a WordPress page that describes the products and services available there, and use it as a gateway to the WHMCS portal located beneath it.
I've tried searching for an answer to this problem, but I keep turning up tons of results about installing wordpress in a subdirectory, and nothing else.
Thanks for your help.
EDIT:
I should have mentioned:
Currently, I get the WHMCS portal when I go to /websites/manage/, which is fine.
However, my problem is that when I go /websites/ I get a directory listing instead of my WordPress page.
I solved this by adding the following to the beginning .htaccess file, before the WordPress section:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/websites/$
RewriteRule . /index.php
</IfModule>
This redirects the /websites/ directory to the /index.php file which WordPress can then use to find its matching page. It still allows the sub directory /websites/manage/ to be controlled by the WHMCS software residing there.

Wordpress installed on my site, but all other files/folders I put in the directory do not show up

Updated Explanation:
I am getting 404 errors for every picture or file I put in the directory via FTP. Here is an example: (The test.html file includes "hello", I've tried html code, css files, images).
The Reason why this is a huge issue is because I am trying to do custom templates for my wordpress site but when I load the .php files (of my templates) on to the server they don't show up in wordpress. Please help me. This problem is impossible to google for/explain well.
RewriteCond %{HTTP_HOST} ^website.net$ [OR]
RewriteCond %{HTTP_HOST} ^www.website.net$
This is probably related to your problem. Your site isn't website.net.
I'm not exactly sure what WordPress has to do with anything since you are not using it for the static html file.

url rewrite using htaccess to force load index.php

I'm trying to make a user-friendly author page url for my wp site. Currently what I have done is I have created a folder by name author under my root theme folder and I have put my author page mark-up file(index.php) inside this folder.
I also have a plugin 'Easy url rewrite' which I'm using to make www.sitename.com/author request to load <theme dir>/author/index.php file. And it is working fine.
Now I want any www.sitename.com/author/<anyname> also to load my index.php file.
Can I achieve this using .htaccess rules? Does .htaccess rule conflict with my url-rewrite plugin?(which one will be executed first?) Can I achieve this whole thing using only .htaccess rules(ie., without the use of plugin rewrite) If so, What rules do I need to write in .htaccess file?
Thanks! Greatly appreciate your help.
Does .htaccess rule conflict with my url-rewrite plugin
yes, probably.
which one will be executed first?
The htaccess rules get executed first, but that's part of how wordpress works. There are rules that essentially send everything to wordpress' controller and then wordpress handles it from there.
Can I achieve this whole thing using only .htaccess rules
It depends. Is your page generated by wordpress or is it just a page by itself separate from wordpress? If it's the former, you're going to need to work on some more easy url rewrite rules, if the author page is separate from wordpress then you can do this entirely with htaccess.
If that's the case, I'd guess the rules would look something like:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^author/(.*)$ /themedir/author/index.php [L]
Those rules need to be before any wordpress rules that you have in the htaccess file in your document root.

Installing Wordpress along side Cakephp

I have cakephp installed in the root directory. site.com/
i want to install wordpress blog at site.com/blog
but since cakephp will redirect all urls i am not sure how to do it ?
From: http://dogmatic69.com/blog/development/7-using-other-apps-with-cakephp-htaccess-config
One thing that is asked quite a lot on #cakephp is how to use other apps alongside CakePHP, and the answer giving is normally pretty ugly. Stick the files/folders in side webroot/. Although that does work, its not very nice. So ill show you a little trick with .htaccess files.
The first (really simple way) is to use a .htaccess inside the sub folder. For example you can have a copy of Joomla! running alongside cake with no issues when you have the .htaccess for Joomla! enabled. If the app does not have one and/or you would not know what to put in the .htaccess file you have another option
Make Apache stop processing rewrites if it finds a request for your sub directory. This is done by adding a rule for the sub directory and then telling Apache it is the last rule to process. The .htaccess file you want to edit is the one found inside your APP directory. All you want to add is the following line:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule (some_folder/.*) $1 [L] # adjust the regex to what you want.
# normal cake rules
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
You can do this for as many sub folders as you wish, by changing the regex accordingly. Its pretty simple to do and a much cleaner way than having all your stuff inside the webroot/ folder of your APP.
Simply put the wordpress install into a "blog" folder in your /app/webroot folder.
Cake will load from the webroot as if the files were in a normal subfolder under a non-cake appliation. You may need to edit / adjust paths in the wp configs or .htaccess files throughout to get everything perfect but it isn't that difficult.
One way to do this is to have your domain pointing to site.com/cakefolder and then have another subdomain blog.site.com pointing to site.com/blog folder
This way to your user, it would always be site.com and blog.site.com

Resources