How to modify the view path with htaccess

1

I'm creating a htaccess to redirect the URL, for example:

I have the following URL:

   www.site.com.br/view/html/cliente.html
   www.site.com.br/view/html/relatorio/demonstrativoDeDebito.html

I would like it to stay that way

   www.site.com.br/cliente
   www.site.com.br/relatorio/demonstrativoDeDebito

My htaccess and this, it just removes the HTML at the end of the files:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
    
asked by anonymous 26.06.2015 / 22:19

1 answer

2

Use RewriteBase and set the entire path in RegEx and the .htaccess file should be in the root folder.

You should use this to point everything to the /view/html folder:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ /view/html/$1.html

You can also check if the path already starts with view/html/ and ignore these:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(?!view/html/.*)(.*)$ view/html/$2.html
    
26.06.2015 / 23:27