Hide folder from URL

Asked

Viewed 2,177 times

0

Guys I’m having difficulty adapting this code, my site is in a folder calls site I want to hide this folder and leave everything if it had the root, until then it works, the problem is when I access the folder 'admin' when I soon get error 404, will anyone can help me

RewriteEngine ON
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(?!site/)(.*)$ site/$1?url_rewrite [QSA,L]

RewriteRule ^(.*)\/(.*)\/(.*)\/(.*)\.html$ index.php?module=$1&page=$2&section=$3&ss=$4&url_rewrite [QSA,L]
RewriteRule ^(.*)\/(.*)\/(.*)\.html$ index.php?module=$1&page=$2&section=$3&url_rewrite [QSA,L]

RewriteRule ^(.*)\/(.*)\.html$ index.php?module=$1&page=$2&url_rewrite [QSA,L]

RewriteRule ^([a-zA-Z]+)?(\/)$ index.php?module=$1&url_rewrite [QSA,L]

php_value upload_max_filesize 32M
php_value post_max_size 32M
  • 1

    has a lot of questions similar to yours, take a peek if you don’t have any answers that help them: Tag htaccess and URL Friendly

1 answer

0


Method A

If you want to prevent the 'skeleton' of the folder site is displayed when accessing the folder directly from the URL (meusite.com/site), as in this example below:

/site
    • imagens
    • js
    • css
       • meusEstilos.css

just add a file inside that folder index.html or a file index.php and add a content dummy in that file. For example:

index.html

<head></head>
<body>
    <h3>Nothing to see here</h3>
</body>

Method B

If you want to choose to use htaccess instead to redirect traffic to the folder site for a 404 page for example, you can do it like this:

RedirectMatch 404 ^/site/.*$

or else

RedirectMatch 301 ^/site/ http://www.meusite.com/?

if you want to redirect traffic to homepage or to a specific page.

  • Thanks for the answers, but unfortunately I don’t think I could express myself. I have the following site http://pingimoveis.com.br it has the front that is inside the folder site, already able to hide this folder from the url with the code I posted but when I soon pingimoveis.com.br/admin (after login) it redirects to page error.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.