htaccess - Rewrite URL with . htaccess inside a subdirectory

Asked

Viewed 200 times

0

I am trying to rewrite a URL where the . htaccess file is inside a subdirectory.

Current URL: localhost/Development/Projects/redirect/index.php

URL I’d like to use: localhost/redirect/index.php

My intention is to hide the path to my index.php, not showing that my structure contains 'Development/Projects'. Also, use the . htaccess file inside the redirect folder as I intend to use one htaccess per project.

Htaccess:

RewriteEngine on

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule ^redirect/ ../../../index.php?url=$1 [L,QSA]

Structure:

  • htdocs (root)
    • index.html
    • Developing
      • Projects
        • redirect
          • index php.
          • .htaccess

1 answer

0

In order for your htaccess to do this it will need to be in the "htdocs folder";

Inside htaccess put the following code:

RewriteEngine on

RewriteRule ^redirect/$ Desenvolvimento/Projetos/redirect/ [QSA,L,NC]

Browser other questions tagged

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