Installing Several Individual Wordpress Sites in Nested subdirectories - php

I have a wordpress installation in my root, here is the .htaccess for it:
I have a directory called /websites in which developers have FTP access to work on client wordpress installations
In this directory could be any number of other wordpress installs such as /company1 /company2 etc.
So the urls for these nested installs would be /wwwroot/websites/company1/ and so forth.
The issue is that while wordpress will let me install into any first level subdirectory from the root, the second nesting breaks the .htaccess.
How can I setup my .htaccess so that when a drop a new site into /wwwroot/websites/base/ it will work as intended?
EDIT: I have tried this suggestion from vico but still get a 404 error in /wwwroot/websites/base/ Here are the exact copies of the files:
/wwwroot/.htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
/wwwroot/websites/.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
/wwwroot/websites/base/.htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /base/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /base/index.php [L]
</IfModule>
# END WordPress
Thanks!

Sorry previous answer was intended for something else.
To install wordpresses in the 2nd Level just remove all first level files and htaccess files
/wwwroot/content/
-/subdir1/
----wordpress file and htaccess here
-/subdir2/
----wordpress file and htaccess here
-/subdir3/
----wordpress file and htaccess here
I think wordpress will take-care of everything if you just move a fresh copy into each directories and run the wordpress setup on each

Related

Wordpress already Installed in root Directory and I have also installed wordpress in subdirectory, But the problem is subdirectory URL is not working

Wordpress already Installed in root Directory and I have also installed wordpress in subdirectory, But the problem is subdirectory URL is not working. It always give 404 error
Root
https://boochcraft.com/
Subdirectory URL
https://boochcraft.com/shop
Root Directory .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
Sub-directory .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /shop/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./shop/index.php [L]
</IfModule>
# END WordPress
Change the sub-directory ".htaccess" to be the same as the original one, no need to prefix your Rewrite rules with "./shop". Then just continue to "boochcraft.com/shop" to continue setup of the 2nd WP with a separate database. If in any case you already have the "boochcraft.com/shop" WP setup, go the corresponding database in the "wp_options" table and change "home" and "site_url" values to "boochcraft.com/shop".
Wordpress rewriting system messes with custom sub-directories.
While you could change the rules in the htaccess, I'd advice you to use a sub-domain instead of a sub directory.
So it would be https://shop.boochcraft.com.
It's usually possible with all main hosting providers. Just install your wordpress in a different folder on the FTP (shop instead of www on the root), and if you're limited to 1 database, don't forget to change the prefix of the shop-wordpress so your two installs don't mix up.
Remove /shop from the last rule in .htaccess file in the sub-directory (RewriteBase stays as before).
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /shop/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

Wordpress redirect to xampp's dashboard except homepage

My system is MAC and I am running Xampp for mac.
I search for many solutions and I thought it must be because of my .htaccess missing file , that all my rest of the links in wordpress even my posts, page except my homepage redirects to localhost/dashboard which is xampp's dashboard.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This is my .htaccess file , and I have all set
<Directory />
AllowOverride all
Require all denied
</Directory>
in apache httpd.conf file
Now what else I can do? I am stuck with this, Even when I click the permalink on my wp-admin page, it shows no object found, 404 error. The page exits, the post exists, everything exists and still I can see only homepage.
Since WordPress seems to be located in /wordpress/, change RewriteRule . /index.php [L] to RewriteRule . /wordpress/index.php [L]?
Should be something like this
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# END WordPress
after hours of search I found that I need to give write permission for my root wordpress folder, hence it was achieved by
sudo chmod -R 777 wordpress
Check your htaccess file. for local version, you need to declare your root folder on the last RewriteRule before the index.php for it to work
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /rootfolder/index.php [L]
</IfModule>

Redirection of website-want to use /en folder being redirected to post

I encountered a strange behaviour with WordPress website.
I have created /en folder in the root and want to have another WordPress website there.
The problems appears when I try to open mainwebsite.com/en I'm being redirected to mainwebsite.com/english-post
So, WP gives the priority to the post that is found in the main domain and it's slug begins with "en".
I tried changing the folders name to "ren" and the website in the folder than shows up nicely.
I've checked .htaccess file for some redirects and none is set.
I noticed that this is a typical WP behaviour, as I tested on some "bigger" brands that use WP and same thing happens,ie:
https://www.smashingmagazine.com/en redirects to --> https://www.smashingmagazine.com/2014/11/enabling-multiscreen-tracking-with-google-analytics/
http://vanheusen.com/en redirects to --> http://vanheusen.com/products/english_shaded_box_silk_tie/
Have any idea how to solve this?
This is my .htaccess file:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !(en/)
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Try using this rule in your main .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^index\.php - [L]
RewriteCond %{REQUEST_URI} !^/en
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
And then you need this rule below in the .htaccess inside en folder
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /en/
RewriteRule ^index\.php - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /en/index.php [L]
</IfModule>
# END WordPress
Let me know how this works

Wordpress - That page can’t be found

I have installed and configured on apache server wordpress (I didn't do that, I am not expert on websites). Now I uploaded my php application so root structure looks like this:
...
images
voucher (this is my application)
wp-admin
wp-content
wp-includes
When I input http://address.com/voucher/index.php into browser I got Wordpress error which contains information "Oops! That page can’t be found.". I don't know why is it trying to achieve my voucher catalog "by Wordpress system", maybe should I set some settings (.htacces or smth like this)?
Wordpress when installed uses rewrite to redirect all requests to index.php by default. If you have other dirs or files on the server you will have to consider them in your .htaccess rules.
Modify your .htaccess. Here is a sample rules that bypasses wordpress rules for your voucher directory.
#only allow the wordpress rules if it is not request /voucher.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} !^/voucher [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Or you can do your rules this way.
#if the request is for the voucher folder, do nothing and display the page
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/voucher [NC]
RewriteRule ^ - [L]
# BEGIN WordPress
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
</IfModule>

WordPress redirection gives 404 after moving site from a server to another

After migrating my WordPress sites from my old hosting provider to my new VPS thought my sites works fine but it was giving 404 not found everywhere
it's a redirection issue because the home page is working fine.
My rewrite mod is activated, the .htaccess is the default WordPress one,
for migrating the site I proceed like this:
I copy the old files in the right vhost folder
I create a mysql username and database for the new server
I update the wp-config.php file with the new params.
I import the old database to the new empty database
I copied this from WordPress official documentation and it worked fine for other sites but now it's not working.
Tried to google the issue but I haven't got the solution.
This is my .htaccess file (standard wordpress):
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
AddHandler x-mapp-php5.5 .php
# BEGIN WordPress
# END WordPress
The solution is so simple but can be caused by various factors
1) You must check if your apache mod_rewrite is enabled
2) Check if Allowoverride is set to All
3) Check if you have a .htaccess file
4) Check if Wordpress have the right to write on it (chmod 666 .htaccess)
for %postname% permalink check if you have a similar .htaccess to this one :
#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>
AddHandler x-mapp-php5.5 .php
# 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
For my case i forgot to set Allowoverride in a correct way

Categories