0
Good when user type some file with the .txt
I have to send it to an authentication file called download.php
Example, if user type www.meusite.com.br/documento.txt
I have to redirect him to the archive download.php
.
I’m trying to do it like this:
RewriteRule ^(.+)\.txt$ Download.php
But instead of redirecting it is opening the txt file in the browser normally.
Someone knows how to do it?
________________ EDIT ___________________ Like this my htacess
# Configurações do url
<IfModule mod_rewrite.c>
RewriteEngine On
# Redirecionamento do Search
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) Site/$1 [QSA,L]
# A menos diretório, remover barra final
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^/]+)/$ http://127.0.0.1/Site/$1 [R=301,L]
# Resolver .php para urls externos php
RewriteRule ^([^/.]+)$ $1.php [L]
# AQUI NÃO ESTA FUNCIONANDO
RewriteRule ^(.*)\.txt$ download.php?arquivo=$1
# Tratamento dos erros
ErrorDocument 500 http://127.0.0.1/erro?n=500
ErrorDocument 403 http://127.0.0.1/erro?n=403
ErrorDocument 404 http://127.0.0.1/erro
</IfModule>
# Evitar a listagem de diretórios
Options -Indexes
# Protege o arquivo .htaccess
<files ~ "^.*\.([Hh][Tt][Aa])">
order allow,deny
deny from all
satisfy all
</files>
# Forçar o uso da codificação UTF-8
<FilesMatch ".(htm|html|php|css|js)$">
AddDefaultCharset UTF-8
</FilesMatch>
# Compressão básica
<IfModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file \.(html?|txt|css|php|js)$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</IfModule>
# Proteger os arquivos e diretórios
<FilesMatch "(\.(Search|CSS|Funcoes|Imagens|Paginas|JS|Modules|Fonts|.*sql|Instalacao|WebServer|Arquivos|Crontab(\.php)? |xtmpl)|code-style\.pl)$">
Order allow,deny
</FilesMatch>
I’m using apache and not Nginx. Well it didn’t work out the way you said, I’ll edit the question with my htacess file.
– Hugo Borges