Htaccess - Rewrite URL with .htaccess within a subdirectory

0

I'm 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
    • Development
      • Projects
        • redirect
          • index.php
          • .htaccess
asked by anonymous 11.01.2018 / 23:12

1 answer

0

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

Within htaccess, put the following code:

RewriteEngine on

RewriteRule ^redirect/$ Desenvolvimento/Projetos/redirect/ [QSA,L,NC]
    
12.01.2018 / 00:10