How to hide the directory paths in the url with htaccess?

2

How do I make all site urls shorten by hiding all directory paths?

For example:

www.meusite.com/models/scripts/arquivo.php
www.meusite.com/view/templates/arquivo.php
www.meusite.com/view/templates/especifica/arquivo.php

And I want you to always stay:

www.meusite.com/arquivo.php

Is this possible? How to make? (already in advance I read all or almost all the main questions about it here on the site and did not find an objective answer.)

  

Update: What I'm looking for is a rule with regular expression that always does this, in all urls, in the response line and in the comments of the @Miguel Neto answer.

    
asked by anonymous 12.11.2015 / 17:50

3 answers

2

Unless you specify the path for each file in .htaccess , or create filename defaults like lib_arquivo.php that will redirect to lib/arquivo.php you can not do with regex only.

Unfortunately, this is not possible due to lack of information. There is no way to retrieve the folder of a given file from a URL without having it mapped.

Another alternative is to use a language and implement Friendly URL .

    
17.11.2015 / 16:36
2

You can use .htaccess to rewrite the URL

Current URL

www.meusite.com/arquivos/arquivo.php

.htaccess

RewriteEngine on
RewriteRule ^arquivo\.php$ arquivos/arquivo.php

URL

www.meusite.com/arquivo.php

You should put .htaccess in the directory of the file in question

    
12.11.2015 / 19:30
1

I do not know if this is the case, but there is also a good way to hide the list of files on your server by doing so:

Options -Indexes
    
12.11.2015 / 19:48