Hiding folder in URL using .htaccess

前端 未结 1 1016
余生分开走
余生分开走 2021-01-28 05:09

I need to hide a folder from a url.

An example:

If I enter www.mysite.com/Jango I need you to read the directory: www.mysite.com/users/Jango

相关标签:
1条回答
  • 2021-01-28 06:00

    This .htaccess in / should do:

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^users/
    RewriteRule ^(.*)$ users/$1 [L]
    

    This treats any requset not starting with users/ as if it did.

    Update:
    If you want the rule to apply for only /Jango --> /users/Jango, this would be an appropriate .htaccess:

    RewriteEngine on
    RewriteCond %{REQUEST_URI} !^users/Jango
    RewriteRule ^Jango/(.*)$ users/Jango/$1 [L]
    

    (The [L]-flag stops rewriting afther this rule, preventing possible circle-reactions etc)

    0 讨论(0)
提交回复
热议问题