skip to Main Content

I have centos7 dedi with latest whm/cpanel install I’ve enabled access to user dirs without domains example http://ip/~user but my target is to be http://ip/user

Now my question would be is it possible to remove ~ and how…?
Googled a lot and read a lot but didn’t found answer…

2

Answers


  1. You might try this:

    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^/([^~/]+?(?:/.*|$)) /~$1 [L]
    

    Warning: the above will rewrite every url to ~url regardless of if the user exists, so if you go to http://IP/exampleurl it will rewrite that to http://IP/~exampleurl, It only checks if a file or a directory exists there.

    Login or Signup to reply.
  2. You really should use your hosts file instead of mod_userdir if you’re trying to view a site before updating the DNS, or before you have a domain for it.

    I can guarantee that mod_userdir will always end up being the unnecessarily difficult solution for this.

    This is a guide for using your hosts file instead of mod_userdir:
    https://docs.cpanel.net/knowledge-base/dns/how-to-modify-your-hosts-file/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search