Update path for Wordpress script-loader.php - php

I'm working on a Wordpress site that is showing some console errors. It is not finding the files for a few scripts that are being loaded from script-loader.php, which is a Wordpress core file.
The issue is that the Wordpress environment for this site contains all the Wordpress core directories and files inside a directory called WP. Since Wordpress is not considering that, it is not able to find the resources since the path is incorrect.
script-loader.php contains this line of code $scripts->add( 'editor', "/wp-admin/js/editor$suffix.js", array( 'utils', 'jquery' ), false, 1 ); if I include /wp/ before wp-admin everything works as intended, but of course, I should not modify a core file.
How can I update the path without modifying a core file so Wordpress will find these files?

Have you gone over the documentation for Having WordPress in a subdirectory? If you installed WordPress under the standard "root path" method, you may need to change your .htaccess file, note specifically the RewriteBase and second RewriteRule:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp/
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wp/index.php [L]
</IfModule>
# END WordPress
There are plenty of other resources on running WordPress from a subdirectory, but the basics generally boil down to:
Make sure your rewrite rules accommodate the directory you're using
Make sure your siteurl and homeurl options are set properly

Related

Wordpress in subfolder insists on showing the parent directory's contents

I'm attempting to migrate our wordpress blog from blog.ourdomain.co.uk to ourdomain.co.uk/journal, but ourdomain.co.uk/journal always shows the content from ourdomain.co.uk/.
To keep the migration simple, I started with a blank wordpress install in /journal, then imported 'All Content' using WP's built in export/import features.
All seemed well at first, but when I visit ourdomain.co.uk/journal it does not show a wordpress home page, but instead the home page of our main site. Even visiting ourdomain.co.uk/journal/index.php results in this behaviour. This site issues a 301 to redirect to ourdomain.co.uk/journal, and then I see the main site homepage rather than wordpress.
I can't see anything in the parent directory .htaccess file which would make this happen. The wordpress .htaccess file contains the code as per below, most of which was auto-created by wordpress, but I added the wp-admin redirect rule.
I can visit and use https://www.ourdomain.co.uk/journal/wp-admin/ no problem. Database cxn is OK. I can also visit static files such as https://www.ourdomain.co.uk/journal/readme.html. Links direct to posts also work fine, such as https://www.ourdomain.co.uk/journal/2021/post-title-here/ - it's just the homepage.
Even if I set the home page to be a static page, such as our about page in wordpress, this still happens.
I have defined define('WP_HOME', 'https://www.ourdomain.co.uk/journal'); and define('WP_SITEURL', 'https://www.ourdomain.co.uk/journal'); in wp-config.php
If I delete the contents of the /journal .htaccess file, then I am able to load https://www.ourdomain.co.uk/journal ONCE, then it goes wrong again because wordpress has rewritten the rewrite code to .htaccess - so clearly this is something to do with permalinks, but I'm unable to figure out what, exactly, the deal is.
Any help gratefully received.
Contents of .htaccess:
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /journal/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /journal/index.php [L]
</IfModule>
# END WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^wp-admin\/?$ wp-admin/index.php [NC]
</IfModule>
OK, has worked for 24 hours now so: fixed by adding 'DirectoryIndex index.php' to .htaccess. Looks like redirection was just going up the folder tree until it found a directory index page it recognised, so making it recognise the one in /journal fixed it.

Unable to upgrade zencart because wordpress is not allowing to access subfolder

Okay,
I have a wordpress system https://example.com, everything works fine. Basically I also have zen cart installed in the system. https://example.com/shopcart/ is the url for zen cart.
I am trying to upgrade zencart to the latest version. For which, I have backed up the files and database.
I have uploaded the latest version zencart files to https://example.com/test/ and when I try to load https://example.com/test/zc_install/ I am redirected to a 404 page.
The <title></title> of the 404 page says 'Nothing found for Test Zc_Install'. I am sure wordpress is looking for an article by this name. I have tried many solutions, but it is not working.
Below is my .htaccess:
`<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>`
The system uses permalinks. The permalink is set to custom structure: http://example.com/%post_id%/%postname%/
I know that wordpress loads the root index.php file first and prepares the query. Is it possible to temporarily stop wordpress behaviours and allow me to access the URL https://example.com/test/zc_install/ ?
Any help would be extremely appreciated. Thank You.
The WordPress apache rewrite is catching all of your requests when they come into the website root directory.
You could add the following to the top of your Rewrite Rules:
RewriteEngine On
RewriteBase /
# add this line to ignore all re-writes within the TEST folder.
RewriteRule ^test - [L,NC]
This will ignore all requests which contain the test/ directory. I would then suggest that you add a separate .htaccess file within your Zen base folder to handle any smart SEO mods etc from there, rather than cluttering your main .htaccess file if possible.

Wordpress permalinks doesn't work on a subfolder installation

The site used to be on the main domain with the plugin "polylang", that created an extension "en" to my domain. I have disabled this plugin and installed a fresh wordpress on a sub folder called "en".
I have kept the same URL's for SEO purposes.
Now when i press on any of the new URL's, If that URL used to exist on the old version of the site (with polylang) - it takes me to the old URL, without the /EN extension.
If i press on a new URL (that didn't exist on the polylang version) it takes me to a 404 page.
I have refreshed the "permalinks" under the page admin several times. made sure the .HTACCESS file is currect:
# 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
Disabled all plugins and moved the the default theme, but still this happens.
I took a look under my wp-config.php file and made sure i have this:
define( 'NOBLOGREDIRECT', 'http://www.med-1.com/en' );
Also i cleared my browsing data.
Any other suggestions ?

404 when WordPress is in a subfolder

I know this question often comes up but none of the answers is satisfactory for me. I tried everything I could find on the web nothing works.
1 - I installed my Wordpress in a sub folder /folder/wp.
2 - I moved .htaccess and index.php to the root ( given by WordPress )
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /folder/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /folder/index.php [L]
</IfModule>
# END WordPress
3 - I changed index.php like this:
/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp/wp-blog-header.php' );
4 - I changed WordPress url: http://localhost/folder/wp
5 - I kept site url: http://localhost/folder
Without Permalinks, everything works.
As soon as I turn on permalinks, I have a 404
There are some things I do not understand:
1 - Why keep index.php and .htaccess in the sub folder?
2 - Some say to add /wp in RewriteBase and RewriteRule in .htaccess at the root, but it does not change?
I read dozens of Post and nothing works for me. Has anyone ever faced this problem?
thank you very much
Something that is not thought is to ensure that the Apache mod_rewrite module is enabled. There are dozens of tutorials on Wordpress installation in a sub folder but none specifies that. I hope this can help.

Main Site Displaying subdirectory in URL

My Main site displays (mypage.com/site) and all following pages include /site as well
How do I achieve (mypage.com) and no subdirectory displaying?
I have tried Removing the /site in the Site Address URL in Wordpress settings.
But it broke my login and disables me from logging in.
what must I do to remove the /site subdirectory folder dislaying on my website?
What do I do in my htaccess file?
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /site/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/index.php [L]
</IfModule>
# END WordPress
I supposed that your WordPress installation is under /site folder. If it's true, you can do it:
If you already has changed the URL, on General panel, to http://mypage.com (without /site), you just need to copy the index.php (under site/) to the root folder.
After copy the index.php file, edit it, adding site/ to the path to wp-blog-header.php:
require( dirname( __FILE__ ) . '/site/wp-blog-header.php' );
The detailed steps of this process are on "Using a pre-existing subdirectory install
" at WordPress docs: http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory
Have you tried to change your document root in Apache?
Something like:
DocumentRoot /path/to/your/site
I don't know if you have access to your hosting, but this would be the best solution as far as I know.
If you can't do it for yourself, you can ask to your hosting provider to do it for you.

Categories