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.)
Related
I've installed a Joomla website in a subfolder of a WordPress site root domain. My goal is to redirect all old url request to new Joomla homepage, except some url.
Assuming www.exampledomain.com is the WP root site, www.exampledomain.com/newsite/ is the new subfolder Joomla site and www.exampledomain.com/some/ is path not to redirect, how can I modify WP .htaccess?
Note that /some/ is not a root subfolder.
Thanks.
If you have mod_rewrite enabled in Apache, you can manually add all of your redirect rules into the WordPress .htaccess file. Here's an explanation of how to do it on Apache's website.
Note that Apache will read and apply all of the .htaccess files between your server root (e.g. /var/www/html by default on a Debian server) and the directory you are serving from (/newsite in your example). There's a possibility you'll have conflicting directives in the WordPress .htaccess file and the Joomla .htaccess file.
You can add an exception to not apply the rule when it matches the /some path
RewriteEngine On
RewriteCond %{REQUEST_URI} !^/some
RewriteRule (.*) /newsite/$1 [L,R=301]
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/
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' );
Right now the index.html of my website is loading from the root directory when someone enters www.mydomain.com in their browser, which as I understand it is the default behavior. I want to move all of my website files into a subdirectory (e.g. public) so that when someone loads www.mydomain.com, the index.html file it loads is in the /public/ directory on my server. However, I do not want the URL to change to www.mydomain.com/public. From there, if a link is clicked/, all of the files will be in the public directory. How would I go about achieving something like that
You can use this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteBase /
RewriteRule ^((?!public/).*) public/$1 [L,NC]
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