Main Site Displaying subdirectory in URL - php

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.

Related

How to get rid of "Index of /" when I visit my test site? [WordPress]

When I visit my site I see something like this:
Index of /
wordpress/
This is what file directory looks like:
.htaccess file:
# Do not remove this line or mod_rewrite rules and search engine friendly URLs will stop working
RewriteBase /
# 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
enter code here
What do I need to do so that when I visit example.com and I see the my wordpress site without the Index of / and list of pages?
The problem is that you do not have any index.php file in your public_html. When you get the directory listing, it is because there is not file inside that directory which matches the DirectoryIndex option. A typically WordPress website will include an index.php, so once you place the WordPress files there, that should go away. You could use Options -Indexes in the .htaccess file to hide that page, but that would give you a 403 error, and still not show your contents, so moving the content into the correct location is what you really want to do.
It appears that you may have placed your files into the directory you named "wordpress". If that is the case, try visiting http://example.com/wordpress/. If that is not what you were wanting, then just move the contents of "wordpress" into the public_html/ directory.

Giving WordPress Its Own Directory when root is redirected to subfolder

So I'm setting up a WP-site on web-server using a subfolder as root for the main-page, and I can't get it to work. The true root is locked, so I can't access that.
The original .htaccess & index.html file is located in ftp://ftp.example//web/
and I want to install my WP in ftp://ftp.example//web/wp.
First I changed the the general settings in WP to:
WordPress Address (URL): http://www.example.com/wp
Site Address (URL): http://www.example.com
Then I copied index.php and htaccess to ftp://einstein.netureza.pt//web/
and changed line 17 in index.php to require( dirname( __FILE__ ) . 'wp/wp-blog-header.php' ); and updated the permalinks in wp-admin.
.htaccess now says:
## Default .htaccess file
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
When I go to my url http://www.example.com I just get this error:
The strategy4change.eu page isn’t working
strategy4change.eu is currently unable to handle this request.
HTTP ERROR 500
However, visiting http://www.example.com/wp works.
I don't have enough reputations to comment. But I hope this is a valid answer:
You missed a forward slash:
require( __DIR__ . '/wp/wp-blog-header.php' );

Remove subfolder name from WordPress site using htaccess

I've moved WordPress into sub-folder named /site but the URL now shows http://www.example.com/site. I want it to show without the /site/ subdirectory.
Here's my current .htaccess code
RewriteEngine On
RewriteBase /site/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /site/index.php [L]
How do I remove the physical subdirectory from the visible URL?
I advice you against messing up the contents of the .htaccess file. Revert the changes that you've made to this file and follow the simple procedue.
Login to the admin dashboard.
Go to Settings > General
In the WordPress Address (URL) field type http://www.example.com/site
In the Site Address (URL) field type http://www.example.com
Save the changes and you should be good to go.
According to Giving WordPress Its Own Directory in the Codex, this is what you need (works for me).
Create a .htaccess file in root folder, and put this content inside (just change example.com and my_subdir):
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/my_subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /my_subdir/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ my_subdir/index.php [L]
</IfModule>
There you will also find instructions to do it by changing the URL in the General Settings, which also requires you to copy .htaccess and index.php, and then edit this last. The first method seems easier.
Try following steps:-
1)Create the new location for the core WordPress files to be stored (we will use /wordpress in our examples). (On linux, use mkdir wordpress from your www directory. You'll probably want to use "chown apache:apache" on the wordpress directory you created.)
2) Go to the General panel.
3) In the box for WordPress address (URL): change the address to the new location of your main WordPress core files. Example: http://example.com/wordpress
4) In the box for Site address (URL): change the address to the root directory's URL. Example: http://example.com
5) Move your WordPress core files to the new location (WordPress address).
6) Copy (NOT MOVE!) the index.php and .htaccess files from the WordPress directory into the root directory of your site (Blog address). The .htaccess file is invisible, so you may have to set your FTP client to show hidden files. If you are not using pretty permalinks, then you may not have a .htaccess file. If you are running WordPress on a Windows (IIS) server and are using pretty permalinks, you'll have a web.config rather than a .htaccess file in your WordPress directory. For the index.php file the instructions remain the same, copy (don't move) the index.php file to your root directory. The web.config file, must be treated differently than the .htaccess file so you must MOVE (DON'T COPY) the web.config file to your root directory.
7) go to index.php.... 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' );

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.

cakePHP hosting not pointing to links

I have hosted my new website here http://cvspforcomval.site90.net/ which is a free hosting site. The problem is that I can't see the pictures in my slide, and when I enter to the navigation links I get an error.
I have changed the default webroot/index.php to:
if (!defined('ROOT')) {
define('ROOT', DS.'home'.DS.'a3503999');
}
if (!defined('APP_DIR')) {
define('APP_DIR', 'app');
and my directory goes like this
/root/
public_html/ <---webroot
app/
lib/
I'm just wondering if using the free hosting site affects the error. Or I just missed something out.
<---EDITED Added below--->
In my shared hosting site. I have setup folder in this way
/app
/public_html <---webrooot
/lib
I have the default htaccess in my public_html which is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
My suspicious is that i need to change my .htaccess. I haven't solved it yet
i am getting page not found error which is due to the anchors. You are not using proper ctp links.You have to create the anchors as
$this->Html->link(__'My Page',array('controller'=>'Home','action'=>'name_of_action'));

Categories