htaccess - Install second wordpress in root subfolder, Error 404

admin2025-01-07  7

I am trying to install wordpress in a subfolder of an existing wordpress installation. I created a the subfolder /wp unziped a fresh Wordpress download inside of that directory and added a .htaccess with the following content:

RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]

However if I visit mysite/wp I get an error 404 not found. I already tried the following: Restarting Apache and adding the .htaccess content to the root .htaccess. But it did not help.

I am trying to install wordpress in a subfolder of an existing wordpress installation. I created a the subfolder /wp unziped a fresh Wordpress download inside of that directory and added a .htaccess with the following content:

RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]

However if I visit mysite.com/wp I get an error 404 not found. I already tried the following: Restarting Apache and adding the .htaccess content to the root .htaccess. But it did not help.

Share Improve this question asked May 23, 2019 at 6:17 Mango DMango D 1013 bronze badges 7
  • Have you confirmed that the /wp subdirectory is included in the WordPress config? What happens when you request example.com/wp/ (with a trailing slash)? I would expect no difference, however, if you omit the trailing slash then you are relying on mod_dir issuing a 301 redirect to append the trailing slash (which is dependent on the DirectorySlash directive). And what if you request example.com/wp/index.php directly? Again that avoids mod_dir having to issue an internal subrequest to the DirectoryIndex. So it's really just ruling our server config issues. – MrWhite Commented May 23, 2019 at 8:07
  • @MrWhite I tried example.com/wp/index.php but I am still redirected to the theme default error 404 page. Also the request in the network tab is showing me error 404 in the header. – Mango D Commented May 23, 2019 at 8:49
  • @MrWhite And what do you mean by "confirmed that the /wp subdirectory is included in the WordPress config"? Adding a trailing slash doesn't provide me any difference in the result. – Mango D Commented May 23, 2019 at 8:59
  • Under WordPress "General Settings", the "WordPress Address (URL)" and "Site Address (URL)" should both include the /wp subdirectory. – MrWhite Commented May 23, 2019 at 11:47
  • @MrWhite I cant check that because Wordpress is not installed yet. Or do you mean the root installation? I tried to add define('WP_HOME','http://new.spirigarchitektur.ch/wp'); and define('WP_SITEURL','http://new.spirigarchitektur.ch/wp');. But it did not help. – Mango D Commented May 24, 2019 at 6:26
 |  Show 2 more comments

1 Answer 1

Reset to default 0

I didn't work with Apache for quite a while, so this is untested. RewriteBase is the base for your rewrite, so it's added to your rule automatically and your .htaccess should look something like this:

RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]

Look here for further explanation: https://stackoverflow.com/questions/704102/how-does-rewritebase-work-in-htaccess

Also, you probably want to only put that in the .htaccess file inside your /wp directory.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736262332a810.html

最新回复(0)