Forum Moderators: rogerd & travelin cat

Message Too Old, No Replies

How to display Wordpress folder on Root?

         

Gemini23

1:54 pm on Sep 18, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Wordpress content is in a folder /wordpress/

Currently, the root homepage is a single html page that I would like to replace

I would like to display the contents of /wordpress/ folder on the homepage (I believe this is possible and have read as such elsewhere but it doesn't appear to work)

I believe something like this can be added to the htaccess but it doesn't appear to work...

RedirectMatch 301 ^/wordpress/$ [domain.tld...]

The contents of the /wordpress/ get displayed as the root - ALL of the posts and pages within the Wordpress folder remain the same.

Help anyone?

not2easy

2:34 pm on Sep 18, 2018 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



All you need to do is make a few changes to your Settings file and some minor edits as listed here - please read all the steps before you start, because you may prefer to do some things in a different order. In general most of this needs to be done in the order listed and there is a point where you can expect errors.

Since your WP install is already in the folder /wordpress/ just log in, go to the Admin > Settings screen where you see settings for Reading, Writing, Permalinks, etc. and under the General heading, make sure the address of your main WordPress core files is shown as http://example.com/wordpress

Now, in Site address (URL): set root directory's URL. Example: http://example.com

Click Save Changes. (Do not worry about the errors that happen now! Continue reading).

Now, Copy (NOT MOVE!) the index.php and .htaccess files from the WordPress directory into the root directory of your site.

Open your root directory's index.php file in a text editor

Change the following and save the file. Change the line that says:
require( dirname( __FILE__ ) . '/wp-blog-header.php' );

to the following, using your directory name for the WordPress core files:
require( dirname( __FILE__ ) . '/wordpress/wp-blog-header.php' );


Login to the new location. It may show at http://example.com/wordpress/wp-admin/

If you have set up Permalinks, go to the Permalinks Screen and update your Permalink structure. WordPress will automatically update your .htaccess file if it has the appropriate file permissions.

If WordPress can't write to your .htaccess file, it will display the new rewrite rules to you, which you should manually copy into your .htaccess file (in the same directory as the main index.php file.)

Note that these steps are available on the WordPress "Giving WordPress Its Own Directory" Codex [codex.wordpress.org] page. I just sorted out the parts that don't apply to what you are doing.

When I mentioned reading through all the instructions, it is because I did not want this part before you could see the rest. When I mentioned some things you might prefer to do a different way, this is what I was thinking of: One of the steps is to copy the index.php file from its /wordpress/ location to your root directory and then edit it. I prefer to ftp a copy to my desktop and edit it there and then upload the new index.php to the root folder. The original stays where it is, in the /wordpress/ folder.

Gemini23

2:49 pm on Sep 18, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Thanks Not2Easy - will the above change all of the urls (posts, pages and assets etc) or will it leave them untouched?

As it is only the /wordpress/ 'page/url' that I would like displayed on the root...

Gemini23

2:56 pm on Sep 18, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



ps - or IF all of the wordpress folder urls will be different - will they automatically redirect to the new urls?

TorontoBoy

3:18 pm on Sep 18, 2018 (gmt 0)

5+ Year Member Top Contributors Of The Month



If it is not too late, please give WP a different directory other than /WP/ or /wordpress/ because bots will easily guess these and try your security. I see these often from bots.

Gemini23

3:38 pm on Sep 18, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



the actual directly is NOT wp or wordpress :)

not2easy

3:46 pm on Sep 18, 2018 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



The URLs would all change according to three changes:
1. The changes in your WP Settings screen
2. The change of putting the edited copy of "index.php" in your root directory
3. The changes to the .htaccess file that is generated by WP - (either generated to your .htaccess file OR shown to you for you to edit your own .htaccess file)

Honest, all the how to is shown at that link. I followed those steps over a decade ago and it works fine.

Changing the name of the /wordpress/ folder is not necessary because the actual name, whatever it is, will be easy to find for anyone interested. It was one of the reasons I decided to do the install that way on that site, but since then I have seen the folder name in many of the headers and other places anyone can see like the page source code. Changing the prefix on your .sql tables helps more than the name of the folder it's in imo.

Gemini23

6:16 pm on Sep 18, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Will the old urls redirect automatically to the new?

not2easy

4:13 am on Sep 19, 2018 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



When you change your settings and update your Permalinks they will all have new URLs.

If you have set up Permalinks, go to the Permalinks Screen and update your Permalink structure. WordPress will automatically update your .htaccess file if it has the appropriate file permissions. If WordPress can't write to your .htaccess file, it will display the new rewrite rules to you, which you should manually copy into your .htaccess file (in the same directory as the main index.php file.)


Gemini23

3:32 pm on Sep 19, 2018 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Hm... all done and working okay but the speed via webpagetest seems to have dropped to over 3s from under 2 - is this likely to be due to the url redirects? Or due to other content added?
Time to First Byte: 1311 ms

Maybe moving the wordpress would be the better option?

not2easy

3:50 pm on Sep 19, 2018 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



It may take time to change things that are cached. Your .sql tables change when the resources are requested. The speed should catch up shortly. If it continues to be slower I'd suggest looking at the requests in your access logs to see how the server is responding. If the proper files are being served, the setup part is complete but both browser cache and CDN (if any) caches need to repopulate.