Wordpress installation in subfolder backend not accessable - wordpress

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

Related

How to install wordpress in laravel public folder

i also follow this link but this is not my solution - laravel and wordpress on the same domain(laravel in subfolder)
i want to add wordpress in my laravel site.
so i install all wordpress in my laravel's public folders. here i create one folder "blog" and in this folder i install my wordpress site.
but my problem is when i run my wordpress site like that localhost:8000/blog it work fine
But when i am try to oprn another link then laravel redirect me 404 page not found.
so how to run wordpress in laravel if make any changes in any file so please any one help me.
my laravel public folder's .htaccess look like that
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
To run wordpress as subdirectory, you must change the .htaccess file inside worpress directory like below:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
Follow this guide for more information
https://wordpress.org/support/article/giving-wordpress-its-own-directory/
Well that quite simple if you have a laravel application such as laravel.
What you have to do is just:
download wordpress form wordpress.org
rename that downloaded wordpress folder to any name such as blog
put that blog folder into a public directory of laravel
put database credential of wordpress blog into wp-config.php
as well as put laravel db credential in .env
make change in .htaccess of laravel
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} http://localhost/laravel/public/$
RewriteCond %{REQUEST_URI} !^/blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /blog/$1
RewriteCond %{HTTP_HOST} http://localhost/laravel/public/$
RewriteRule ^(/)?$ blog/index.php [L]
</IfModule>
You can easily access your blog as
http://localhost/laravel/public/blog
It will start wordpress blog

How to ignore sub-folder requests and continue processing URI mapping using mod_rewrite?

An default example file for a default Wordpress deployment is:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I have a special case scenario though where I have a subfolder as such in my root web directory that I need ignored:
/folderA/folderB/specialCase.php
I basically need:
/folderA/folderB/*
to be ignored, but I do need:
/folderA/folderB/specialCase.php
to be directly accessible and served.
The problem is that /folderA/folderB currently maps to a URI in my Wordpress install. Since the directories actually exist in the web root folder, currently Apache is serving up the index.php within /folderA/folderB/.
I need it to skip over these subfolders and continue processing URI mappings as usual, except in the special case where specialCase.php is requested?
Difficult? Hard? I'm stumped at the moment. Have been experimenting with the [PT] (passthrough) flags but no luck so far.
Thanks!
Couldn't you just check for that specific file, and serve it. Otherwise redirect the rest to the wordpress rules. Maybe something like this.
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/folderA/folderB/specialCase\.php$ [NC]
RewriteRule ^ - [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_URI} ^/folderA/folderB/?$ [NC,OR]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Also you could probably add another .htaccess in folderA/folderB/.htaccess with this
DirectoryIndex disabled
Which will also prevent it from serving index.php in that directory only.

.htaccess, WordPress and mod_speling

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?

Rewrite index and one folder to static pages with WordPress rewrites on the other

I'm looking to have all WordPress rewrites to work except:
Home page as a static html page, content is in index.html in the root folder
/business be routed to a business folder in the root dir which contains static html pages.
When I set the index to . /index.html [L] none of the regular wordpress rewrites work. However if I set DirectoryIndex /index.html I can't figure out how to get rewrites to work for /business which contains HTML files that need to be served up on the http://mywebsite.com/business url. Full rewrite rules:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule . /index.php [L]
RewriteRule . /index.html [L]
Any help is appreciated and, more than just an answer, an explanation of what each portion of the lines you provide does may help myself and others understand how to take this on on their own next time.
UPDATE: Rules are still not working. /wp-admin has worked all along though.
Try to stick with default WordPress rewrites and simply add DirectoryIndex to prefer .html files over .php files:
DirectoryIndex index.html index.php
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
So rewrites will only happen when requested files or directories are missing (RewriteConds with !-f and !-d flags). And if there is a static index.html along with index.php in a directory (root directory for example), it will be served first.
http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex
Try:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteRule ^business/ - [L]
RewriteRule ^index\.php$ - [L]
RewriteRule ^$ /index.html [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Two issues need to be solved:
Serve a particular HTML file whenever someone needs the front page.
Serve static files from a static directory alongside WordPress.
To solve the first issue, I would rename index.html to front-page.php and move it inside my current theme folder. Then WordPress would serve it (or rather: use it as a template) whenever someone requests the front page, according to the Template Hierarchy.
There is a cost to this solution compared to actually serving a static file: Whenever someone requests you front page, WordPress will still be loaded. If the goal of serving your front page statically is to save server resources by not loading WordPress or PHP on every page load, you should look into caching plugins.
The second issue should not be an issue at all, because the standard WordPress rewrite rules already allow for static files and directories. The lines
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
mean that the redirect to WordPress won't happen if the URL requested is an actual file (-f) or directory (-d). Therefore you will not need any extra rewrite rules to access the /business directory.
The standard WordPress rewrite rules are explained below:
RewriteEngine On # Turn on the rewrite engine
RewriteBase / # Use the domain root as the base of rewrites
RewriteRule ^index\.php$ - [L] # If someone requests the WordPress entry point, stop here
RewriteCond %{REQUEST_FILENAME} !-f # If the requested URL is not an actual file ...
RewriteCond %{REQUEST_FILENAME} !-d # ... and if the requested URL is not an actual directory ...
RewriteRule . /index.php [L] # ... then rewrite it to the main WordPress entry point
When /index.php is loaded, this file will then in turn load WordPress and everything that comes with it.
Replace this code with your HTACCESS file in root
# Switch rewrite engine off in case this was installed under HostPay.
RewriteEngine Off
SetEnv DEFAULT_PHP_VERSION 53
DirectoryIndex index.cgi index.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
And also change the URL's from database...

.htaccess remove subdirectory name from all URLs

I was digging the net and haven't found any proper solution for this issue. Basically, I want to remove subdirectory (subdirname) name from all URLs, e.g.:
http://test.com/subdirname/
http://test.com/subdirname/content/
http://test.com/subdirname/content/newpage
The website is based on Wordpress and located in /subdirname. I've got two .htaccess files, one in root directory:
# Turn on URL rewriting
RewriteEngine On
# Installation directory
RewriteBase /
# Protect hidden files from being viewed
<Files .*>
Order Deny,Allow
Deny From All
</Files>
# Protect application and system files from being viewed
RewriteRule ^(?:application|modules|system)\b.* index.php/$0 [L]
# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
#RewriteCond %{REQUEST_FILENAME} !-d
#RewriteCond %{REQUEST_URI} !^(/var|/static)
#RewriteCond %{REQUEST_URI} !^(/index\.php|/var|/static)
# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT]
RewriteCond %{HTTP_HOST} ^(www\.)?test\.com$ [NC]
RewriteCond %{REQUEST_FILENAME} !/subdirname/
RewriteRule ^(.*)$ /subdirname/$1 [L]
and second in /subdirname/ directory:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdirname/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /subdirname/index.php [L]
</IfModule>
# END WordPress
If anyone has some tips how to solve it, please advice.
You should be able to set up WordPress to display at your root domain but be installed in the subdirectory. Just change ONLY the site URL under the Settings-> General screen. Leave the subdirectory in the WordPress URL box. Then you would login at http://yoursite.com/subdirectory/wp-admin, but folks visit your site at http://yoursite.com.

Resources