.htaccess, WordPress and mod_speling - wordpress

I've got a server that has in its root directory a bunch of subdirectories, one of which has a WordPress.
directory1
directory2
wordpress
directory3
All of these except for the WordPress were migrated from a Windows server to a Linux server which means that we've lost case insensitivity.
I want the WordPress to be able to serve a URL like http://www.example.com/~subdomain, so there's an index file in the root directory. I also have two .htaccess files, one in the WordPress and one in the root directory.
The following is the root directory's .htaccess.
This is where I'd like to put mod_speling's case insensitivity directives, but it conflicts with the rewrite rule.
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~subdomain/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~subdomain/index.php [L]
</IfModule>
# END WordPress
Below is the WordPress subdirectory's .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~subdomain/wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~subdomain/wordpress/index.php [L]
</IfModule>
# END WordPress
I've tried using a symlink in the root directory to point to the WordPress directory's index.php. I set the symlink to be the DirectoryIndex but unfortunately it results in a lot of the links turning into 404s.
At this point I'm kind of stuck. Any ideas?

Related

Wordpress installation in subfolder backend not accessable

I have a Wordpress installation in the root folder of my server and another Wordpress installation in a subfolder called "neueseite".
I can access the frontend of the page in the subfolder but not the admin area (backend). When I try to access it, it shows me a 404 error: https://paarkultur.ch/neueseite/wp-login.php
All URLs in the database contain the URL with the subfolder. I also tried different things with the .htaccess file. Nothing helped.
Here is the code inside the root directory's .htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
# Include in the next line all folders to exclude
RewriteCond %{REQUEST_URI} !(neueseite) [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
And this is the code in the subfolders .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /neueseite/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /neueseite/index.php [L]
</IfModule>
Can someone help me figure out what the problem could be?
I checked your nginx server and the below file is not located in the directory listed below:
https://paarkultur.ch/neueseite/wp-login.php
I can see that you have various core files such as wp-config.php, readme.html, etc but you do not have wp-login.php in that directory.
Anyway if you are trying to serve multiple sites from a single server then you are going the wrong way about it

htaccess rewrite issue excluding folder

I have a Wordpress site that has a rewrite rule. I also have a non-wordpress folder, but I can't access it because of this rule. So I read that i should enter RewriteEngine Off in the htaccess of the non-wordpress folder, unfortunately I still get an Error 404 on that page (it works fine if I remove the Wordpress rewrite).
Here is the htaccess in the 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>
# END WordPress
What am I doing wrong?
Many thanks!
Matt
Add this right under RewriteBase /:
RewriteRule ^folder/ - [L]
where folder is the folder you want to exclude.

Can I have another publicly accessible directory on Wordpress server?

I have a Wordpress site hosted by BlueHost. Is there a way I can create a new subdirectory under public_html that would not redirect to my Wordpress site? Do I need to modify the .htaccess file?
UPDATE:
Here's the .htaccess file currently:
# Use PHP5.4 as default
AddHandler application/x-httpd-php54 .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /~user/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /~user/index.php [L]
</IfModule>
# END WordPress
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
The above rewrite conditional checks validate that URL rewriting should only be done when the requested resource is not a readable directory or file. So if you have your public_html laid out as such:
public_html/
wp-admin/
...
wp-content/
...
wp-includes/
...
my-sub-site/
index.php
...
.htaccess
index.php
...
Then you should be able to access the my-sub-site/index.php without problems, as it exists and is readable (validate rwx access rights if it is not).

.htaccess for 2 CMS in different directories

My site is set up with 2 CMS syatems
In the root domain there is a Joomla website and in another directory called /word/ there is a wordpress directory.
The site originally was the wordpress site and this was moved to /word/ directory but to maintain all the original url's, I used mod_rewrite which works great until I insert the mod_rewrite for the Joomla site.
The mod_rewrite works great for the Joomla site but blocks all access to /word/ directory and 404 errors are thrown up. And if I leave the Joomla code out of the .htaccess I am left with the trailing /index.php/page name.
I have in my .htaccess file (This stops access to the /word/directory)
# Begin Joomla
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /word/index.php [L]
</IfModule>
# END WordPress
How can these 2 live together?
Joomla comes with its own .htaccess template which should be in the root folder and called htaccess.txt. Usually, I would rename to .htaccess and then un-comment this line:
# RewriteBase /
to:
RewriteBase /
My suggest would be to replace your "Joomla" section with the one provided by Joomla and see if that does the trick.

WordPress in root folder and vBulletin in subfolder

I installed WordPress in my host root folder and I installed vBulletin in a subfolder.
I changed my WordPress default permalink to "postname".
Now when I want to open forum (the vBulletin subfolder), it redirects to root folder (WordPress) and gives "not found post".
When I delete .htaccess file in the root folder (WordPress), the subfolder works fine, but accessing WordPress posts gives 404 error.
How can I solve this problem?
It is my WordPress .htaccess file:
# 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 this is the subfolder (vBulletin) .htaccess file:
# Comment the following line (add '#' at the beginning)
# to disable mod_rewrite functions.
# Please note: you still need to disable the hack in
# the vBSEO control panel to stop url rewrites.
RewriteEngine on
# Some servers require the Rewritebase directive to be
# enabled (remove '#' at the beginning to activate)
# Please note: when enabled, you must include the path
# to your root vB folder (i.e. RewriteBase /forums/)
#RewriteBase /
RewriteCond %{HTTP_HOST} !^soft-game\.ir
RewriteRule (.*) http://soft-game.ir/forums/$1 [L,R=301]
RewriteRule ^((urllist|sitemap_).*\.(xml|txt)(\.gz)?)$ vbseo_sitemap/vbseo_getsitemap.php?sitemap=$1 [L]
RewriteCond %{REQUEST_URI} !(admincp/|modcp/|cron|vbseo_sitemap|api\.php)
RewriteRule ^((archive/)?(.*\.php(/.*)?))$ vbseo.php [L,QSA]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !/(admincp|modcp|clientscript|cpstyles|images)/
RewriteRule ^(.+)$ vbseo.php [L,QSA]
You should install wordpress and vBulletin in seperate folders, because a sub-folder in the wordpress insallation means that it is part of wordpress, and it will not act as an unique entity.
Create two folders, name first as 'blogs' or whatever for wordpress and create another folder in the root and name it 'forums' or whatever you like for vBulletin only then the 404 error from wordpress will disappear.

Resources