Htaccess adding contents of shared file system in url

59 Views Asked by At

I have setup a completely free website with x10hosting and freenom (.ml). In this website I have an account subdomain that uses the contents of the /account/ directory in the public_html directory.

It all works fine, but when http://account.lynk.ml/login gets rewritten, it rewrites to http://www.account.lynk.ml/home/MYUSERNAME/public_html/account/login.php.

Is there anyway to make it have the url http://account.lynk.ml/login? Thanks in advance.

Subdomain code in htaccess:

# Account subdomain
RewriteCond %{HTTP_HOST} ^account\.lynk\.ml$
RewriteCond %{REQUEST_URI} !^/account/
RewriteRule (.*) /account/$1

I am new to subdomains, so don't expect much knowledge from me. ;)

1

There are 1 best solutions below

4
On

Something such as the following should be what you might be looking for; It essentially will rewrite anything from subdomain.example.com or subdomain.example.com/account to /login:

RewriteEngine On
RedirectMatch ^/$ /login
RewriteRule ^login account/$1
RewriteCond %{THE_REQUEST} ^GET\ /account/
RewriteRule ^account/(.*) /login/$1 [L,R=301]

This leaves the content in /account and makes the url appear as /login