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 http://www.example.com. Let me explain step by step.
So finally I managed to get what I want to be working with below solution. Hopefully this will help somebody out there:
For WordPress part, I have put codes in
wp-config.php
as below: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?