I have installed the site in a subfolder of an existing site. When I open the home page, the url looks like this: www.nextarconsulting.com/SitoNextar/
I would like it to appear instead: www.nextarconsulting.com
I tried different solutions via .htacces but no one works!
PS: The old site (where I have the subfolder with the new wordpress installation) has the same url as the new site, so I have 2 equal link redirects after I modify the .htaccess of the new site. Can this be in conflict?
Here is my .htaccess file :
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /SitoNextar/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /SitoNextar/index.php [L]
</IfModule>
# END WordPress
# BEGIN Hotlinking
# END Hotlinking
I would also like to see that the other pages of the site no longer appear on the folder path. For example: www.nextarconsulting.com/SitoNextar/contacts.html must become
www.nextarconsulting.com/contacts.html
You do this through Wordpress Settings, the index.php and .htaccess files.
Go to the General Settings in your Admin area. You will see that "WordPress Address" and "Site Address" fields will have the same URL. You need to change the Site Address option to point to your root domain, i.e. http://www.nextarconsulting.com and leave WordPress Address option as it is.
Copy the .htaccess file from the installation subfolder (i.e. SitoNextar) to the domain root folder
Copy the site's index.php file from the installation subfolder (i.e. SitoNextar) to the domain root folder, and edit it as follows:
Change this line in index.php:
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
to include the installation folder, e.g.:
require( dirname( __FILE__ ) . '/SitoNextar/wp-blog-header.php' );
Notes:
You might also need to resave your permalinks after doing this.
You still login and use the Admin area from the installation folder (i.e. www.nextarconsulting.com/SitoNextar/wp-admin)
Reference: [How to Get Rid of /wordpress/ From your WordPress Site URL](http://www.wpbeginner.com/wp-tutorials/how-to-get-rid-of-wordpress-from-your-wordpress-site-url/
Related
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' );
I am no .htaccess expert and extremely rarely use it. I went through several solutions on Net and SO but no luck still. So I have one IP says 1.2.3.4 that has sub folder of my wordpress application says ABC in the /var/www/html/. DNS has been setup so that www.mydomain.com and mydomain.com point to IP 1.2.3.4.
I have my content in .htaccess file as below and it only supports mydomain.com. The content is displayed as expected except when I put www.mydomain.com it displays Linux home page.
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^mydomain\.com$
RewriteCond %{REQUEST_URI} !^/ABC/
RewriteRule (.*) /ABC/$1
When I put www.mydomain.com the browser automatically change the URL to mydomain.com.
Apart from that, I would also like to have all domain with www. Means request from mydomain.com will be displayed as www.mydomain.com. Later I will just put www.mydomain.com in the URL config of my wordpress. Some helps are appreciated.
Switch back to your old .htaccess code. I got it more clear after your last update. You have wordpress files in "public_html/ABC" but need your website url as www.example.com. Let me explain step by step.
Paste your old code in .htaccess.
copy (do not move) the index.php and .htaccess file from the /ABC folder to the "public_html" of your site.
Find one rule in "public_html/index.php" as "require( dirname( FILE ) . '/wp-blog-header.php' );" and replace it with "require( dirname( FILE ) . '/ABC/wp-blog-header.php' );" (do not edit the index.php file in the folder /ABC!!)
change ONLY the "Site Address (URL)" in the general settings (Settings -> General) to "http://www.example.com".
So finally I managed to get what I want to be working with below solution. Hopefully this will help somebody out there:
RewriteEngine on
RewriteBase /
# Whatever request coming to the server, add www to it
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
# Map the www URL to the subfolder in root directory
RewriteCond %{HTTP_HOST} www\.myurl\.com$
RewriteCond %{REQUEST_URI} !^/thefolder/
RewriteRule (.*) /thefolder/$1
For Wordpress part, I have put codes in wp-config.php as below:
define('WP_HOME','http://www.myurl.com');
define('WP_SITEURL','http://www.myurl.com');
Thank you. Cheers.
UPDATE
I have just realized that after the changes above, I could not able to login to my WP admin page. This is due to wrong redirect. It looks something like http://www.myurl.com/wp-login.php?redirect_to=http%3A%2F%2Fwww.myurl.com%2Fthefolder%2Fwp-admin%2F&reauth=1
When I remove the thefolder from URL it redirects to expected page. Can somebody advice on this?
I would like to run a wordpress site through a subdirectory but keep the actual domain.
Here is what I am trying to do.
Let's say, I have a site www.xyz.com
I have a wordpress instance installed on the root directory. However, i want to install a new wordpress instance in a subdirectory. I want to point the root worpdress instance to the subdirectory and keep the domain name without referencing to the subdirectory.
The subdirectory can be called let's say "test". In the test directory, I will install a new wordpress instance.
Now, I want to point www.xyz.com to the "test" directory and still have the link as www.xyz.com. All the links should be www.xyz.com/post-name-sample and not www.xyz.com/test/post-name-sample.
Is there a mod-rewrite rule I need to setup within the .htaccess file?
Any help is appreciate. Thank you!
Try adding this to the .htaccess file
.htaccess main domain to subfolder redirect
# Copy and paste the following code into the .htaccess file
# in the public_html folder of your hosting account
# make the changes to the file according to the instructions.
# Do not change this line.
RewriteEngine on
# Change yourdomain.co.uk to be your main domain.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.co.uk$
# Change ‘subfolder’ to be the folder you will use for your main domain.
RewriteCond %{REQUEST_URI} !^/subfolder/
# Don’t change this line.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Change ‘subfolder’ to be the folder you will use for your main domain.
RewriteRule ^(.*)$ /subfolder/$1
# Change yourdomain.co.uk to be your main domain again.
# Change ‘subfolder’ to be the folder you will use for your main domain
# followed by / then the main file for your site, index.php, index.html, etc.
RewriteCond %{HTTP_HOST} ^(www.)?yourmaindomain.co.uk$
RewriteRule ^(/)?$ subfolder/index.php [L]
It is possible to do with on wordpress: here is how to do it if you have it installed in a subdirectory already.
Go to the General panel.
In the box for Site address (URL): change
the address to the root directory's URL. Example: http://example.com
Click Save Changes. (Do not worry about the error message and do not
try to see your blog at this point! You will probably get a message
about file not found.)
Copy (NOT MOVE!) the index.php and .htaccess
files from the WordPress (wordpress in our example) directory into
the root directory of your site—the latter is probably named
something like www or public_html. 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.
Edit your root directory's index.php.
Open your root directory's index.php file in
a text editor
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' );
Save the file.
Login to your site
(if you aren't still already). The URL should still be
http://example.com/wordpress/wp-admin/
If you have set up
Permalinks, go to the Permalinks panel 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.)
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.
I have Wordpress installed in a subfolder: www.mydomain.com/p/
I want the front page of www.mydomain.com to show the wordpress ( /p/index.php ) frontpage. I don't want a redirect.
I have tried with this in my root .htaccess:
Directoryindex index.php /p/index.php
Theres is no index.php file in the root, so it uses the Wordpress index.
It works, but with one problem:
It does not update the page on www.mydomain.com but only on /p/index.php
I use the plugin WP Super Cache.
Is there another solution to doing what i want?
Thanks
The main thing is you can redirect using htacess but my suggestion
you just have to move your file from www.example.com/p/ to www.example.com and change links in database
because each links will redirect from www.example.com/p/
You no need to redirect subfolder to main domain plz move the files to main domain. If u using ftp select files and drag into domain path folder like htdocs / www/ or you can move using cpanel
Otherwise
The possible and simple way in htaccss we can redirect main domain into sub domain.
If you want to do the same as you asked plz refer this link I it will help full.
https://my.bluehost.com/cgi/help/htaccess_redirect
Okay so I want to share the answer I found a while ago:
Go to Wordpress settings -> general settings, set the WordPress Address (URL) to:
http://www.example.com/p
Copy index.php to the root folder.
Edit the root index.php so it includes the wp-blog-header.php from the sub folder:
require('./p/wp-blog-header.php');
The root .htaccess should have this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress