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
Related
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' );
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?
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.
This is our situation: The original domain name (say, www.example.com) was done in WordPress and installed in the root. We have created a new website using Joomla and placed it in a sub-directory (say, www.example.com/PORTALsite).
I have been able to successfully redirect the root (www.example.com/) to this sub-directory (www.example.com/PORTALsite) using this code in htaccess:
RewriteEngine on
RewriteRule ^$ http://www.example.com/PORTALsite [R=301,L]
This works good, EXCEPT that we need the original WordPress website (the Home page located at www.example.com/index.php) to still function. We need this, because we have hundreds of pages within this WordPress site that are indexed in the Search Engines and we want all of that old content to continue to function.
The code above works well for all files and sub-directories within the Root, allowing our old content to continue to function, and it correctly redirects the root itself (www.example.com/) to the new Joomla website's sub-directory (www.example.com/PORTALsite).
HOWEVER, the problem is this: We still need the old WordPress site's index.php file to function if it is accessed directly (i.e., if someone types in www.example.com/index.php), BUT it is NOT functioning. If you go to www.example.com/index.php is also redirects to www.example.com/PORTALsite. Though all of the other files in the root still function as we desired them to.
Let me make sure I am explaining this properly: If someone goes our domain (www.example.com) it redirects as we want to the new Joomla website (at www.example.com/PORTALsite). BUT, if you go to www.example.com/index.php (the old WordPress site's Home page) it also redirects to the new Joomla website's sub-directory (www.example.com/PORTALsite). We do Not want this to happen. We want it so that if the root's index.php file is accessed directly, that it will still function (to keep all the old WordPress content intact).
We ONLY want requests to the domain name itself, www.example.com, to redirect to www.example.com/PORTALsite. But, we need all of the other files and sub-directories, including www.example.com/index.php, to still function (so that people can still access all of the old WordPress website's content, as well as numerous static pages).
All the files and sub-directories in the root (www.example.com/) still function as we want, BUT just the old WordPress site's Home page (located at www.example.com/index.php) also redirects to the new site at www.example.com/PORTALsite (along with requests for the domain name itself www.example.com). So the code above is VERY close to working as we desire.
I greatly appreciate the expertise here on StackOverflow and greatly appreciate any help we can receive. Thank you in advance!
UPDATE: This is the code in our HTACCESS file: (used "example.com" rather than true domain name)
RewriteEngine on
RewriteRule ^$ http://www.example.com/PORTALsite [R=301,L]
# 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
In light of anubhava responses below, his code should work once I get WordPress to stop removing the "index.php" from the URL. Thank you anubhava! Here's the whole file.
Replace this rule:
RewriteRule ^$ http://www.example.com/PORTALsite [R=301,L]
with this:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+[\s?]
RewriteRule ^$ /PORTALsite [R=301,L]
Make sure this is first rule in your wordpress .htaccess
Make sure to test in a different browser to avoid 301 caching issues
Change permalink setting of WP to make your BLOG/Home URLs as http://domain.com/index.php instead of http://domain.com/