Wordpress install in root and in subfolder + two domains - php

God, this little problem drives me crazy and I really hope that you'll help me how to figure it out.
I searched over all previous threads and in the codex of wordpress, didn't find my exact problem.
This is it :
I've one host with a wordpress installed at the root. I've one domain pointing it. Everything is fine.
I've need now a second install of wordpress, that i've installed in a subfolder. I've a second domain, linked to this subdfoler.
Like this :
root > domain.net
root/subfolder > anotherdomain.net
If I let the "site url" setting and the "wordpress url" setting with "domain.net/subfolder", this is OK, I can access to my second site and all permalinks work.
But if I edit my site url/wordpress url in "anotherdomain.net" it renders the "domain.net" homepage without style...
I'm sure this is a question of HTACCESS but I can't find how to properly write it...
Thanks for your answers !
(sorry for my english, not my mother tongue)
EDIT : Here are .htaccess (at this state, I let them in order to access subfolder via domain.net/subfolder)
root:
# 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>
root/subfolder
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subfolder
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subfolder/index.php [L]
</IfModule>
# END WordPress

HTACCESS would be my first guess too, but another thought occurred to me: have you made sure that you are installing the two sites in two distinct SQL databases?
Assuming this is not the problem, is there any way you paste your htaccess files, so I can see if there is an issue in them?

All the config were good, the problem was with my host provider.
For the record, the htaccess for the site in the subfolder, when everything is ok :
# 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
And the site and wordpress urls pointing to the new domain.

Related

wordpress 404 error when trying to acess folder on root

I have a wordpress website and within the root directory a folder called /ideal/.
The function for the /ideal/ folder is to make payments trough the website from visitors.
Everything worked well for a while, since a few days there is a problem with the page.
When i navigate to my website http://www.nibincasso.nl/ideal/ it wil show up with a 404 error.
With the release of wordpress 4.0 it looks like wordpress is trying to make some sort of dynamic link for the folder /ideal/.
However i want it to open as a static page, not by making it a wordpress dynamic page. “http://www.nibincasso.nl/ideal/index.php”.
Example of .htaccess:
# 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
Can someone help me with a solution for this problem?
Kind regards,
Fabi
Update *
I created a new subdirectory on my root with a blank index.php page only saying test
This one opens fine. But when i try to enter the subdirectory /ideal/ with the index.php i get a 404 error. How come?
Try following
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /ideal/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /ideal/index.php [L]
</IfModule>
# END WordPress
There seems to be a problem with the php code inside the index from the /ideal/ folder.
I will search for the solution this is not a wordpress problem.
Thanks for helping me for so far.

Wordpress .htaccess\domain name trouble

Got pulled in the last second because someone made a minor tweak to a WP site of ours and removed "www." (or so I am told) from the url. Now the page can only be reached by typing in wxyz.com (example). So, I speculated it was a .htaccess write and told my friend who is attached to that project about it. He agreed to try, but handed it off to me due to time constraints.
So I looked at it- for some 3hrs. An amazingly simple little problem and clearly I am missing something.
The other developer said all he did was add:
RewriteCond %{HTTP_HOST} !^kokonut\.com$ [NC]
RewriteRule (.*) http://kokonut.com/$1 [R=301,L]
But none of my code or tweaks to his would change anything, first of all. The site wouldn't ever work.
Secondly, WP has a front end system to change the url's so after this failed I thought "well, ok, I'll just go there and say "www" in front. That broke everything, the admin panel wouldn't even work anymore!
So I had to go into wp-config.php and explicitly say:
define('WP_HOME','http://wxyz.com');
define('WP_SITEURL','http://wxyz.com');
But this was just getting back to where we started! Further, without that code up there sometimes the site just won't work whatsoever.
The current .htaccess file is as written (which is DIFFERENT than his original, apparently WP overwrote it but restoring it to how it was won't do much of anything either or so it appears to me. Honestly at this point I may be running myself in circles.):
# 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
How it was when I was first assigned to "fix" it:
# 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]
RewriteCond %{HTTP_HOST} !^wxyz\.com$ [NC]
RewriteRule (.*) http://wxyz.com/$1 [R=301,L]
</IfModule>
# END WordPress
So what am I missing here? Obviously he could change it from www --> nothing without a problem, why is reverting it back so arduous?
I've never worked on this site, this server or with this group before. So this is a first. I've dabbled with .htaccess but I'm not "an expert", if I were I would certainly not be in this pickle!
Any help is appreciated.
Not sure if this is the source of your issues, but one big problem is that wordpress has a routing rule (RewriteRule . /index.php [L]) and then you have a redirect rule RewriteRule (.*) http://wxyz.com/$1 [R=301,L], which is fine, except that you're redirecting after you route. External redirects must happen before the server internally routes things. Additionally, wordpress will overwrite the rules that are inbetween the # BEGIN/END WordPress comments. So if you don't want wordpress to overwrite rules that you add, you need to include them outside of that block:
<IfModule mod_rewrite.c>
RewriteCond %{HTTP_HOST} !^wxyz\.com$ [NC]
RewriteRule (.*) http://wxyz.com/$1 [R=301,L]
</IfModule>
# 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

Redirect to outside Wordpress

I have a folder called "stats" on my server that I cannot access anymore because wordpress redirects it to the "Page not found". This folder has nothing to do with wordpress. I have searched for a solution but nothing seems to be working. I am using the theme elegant fusion.
For clarification, the folder is on the same level directory wise as "wp-admin", "wp-content", "wp-includes".
Does anyone know how I can access my folder without going through wordpress?
Thank you in advance!
Enable searach engine optimised permalinks is the answer. I am thinking you must be using the default permalinks, by enabling seo permalinks in Settings->Permalinks in the backend will create (assuming permissions allow, if not you do it manually) an .htaccess file in the root of your install like so;
# 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
The two lines that will solve your problem are;
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
Which tell wordpress to ignore any url which is for an actual directory or file. Anything else gets rewritten by Wordpress.

Some FTP updates don't take effect, some do

I'm wondering if anyone can help me, I'm running WP and I'm uploading and replacing files and SOME of the changes are there...
Then when I Inspect Element it's showing the OLD CSS. How is this happening? It's like it's caching my styles on the server for some reason?
This is my .htaccess file:
# Begin default subdomain redirect #
RewriteEngine on
RewriteCond %{HTTP_HOST} ^deadlineday.co
RewriteRule ^(.*)$ http://www.deadlineday.co/$1 [R=permanent,L]
# End default subdomain redirect #
# 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
Thanks in advance...
It has happened to me a couple of times. In my case, the source files have path from "cdn", so we usually purge cdn cache for changes to be reflected on the server.
Is your case similar?

Website redirection problems

I have been working on a website that is primarily PHP based. When a user visits the site stuff like http://robroscoe.ca/index.php, is redirected to http://robroscoe.ca and I am okay with this. What I am not okay with is, my webpages like robroscoe.ca/cv.php when you type in robroscoe.ca/cv redirecting back to robroscoe.ca. I am not sure how this happened and I am wondering if someone could explain to me what is going on.
# 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 think the .htaccess file has something to do with this but I am not sure how to modify this as Wordpress seems to have created this for me without me knowing it. Any help or reading materials would be appreciated.
Thanks for your time!
You problem is that you've created a PHP script that is separate from WordPress and are trying to access it through a 'pretty' URL which WordPress handles. WordPress does not know of a page called 'cv', and handles it like any other 404.
I would strongly recommend that you create the page within WP so it can manage its own 'pretty URL' structure.
If you're hellbent on shoehorning your own scripts in, then get cozy with hand-editing your .htaccess file for each one.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^cv/?$ cv.php [L] #new rule
RewriteRule ^index\.php$ - [L] #this is made redundant by the very next line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Categories