Doubt in . htacess

Asked

Viewed 62 times

0

Guys, I do a internship at a web development company and tals and a little while ago we had a problem in redirecting the page.

In the company we used for this project Php MVC (I never got to delve into Php) and a file . htacess that also had never seen.

So about this file, can you explain to me what this code is doing?

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteCond %{REQUEST_FILENAME} !-f [OR]
RewriteCond %{REQUEST_FILENAME} (\.php)$

#RewriteBase /projetos/c/*****/dev/acompanhamentoobra/
RewriteBase /acompanhamentoobra/

RewriteRule ^(.+)$ index.php?path=$1 [QSA,L]
  • Please, if you know a material that teaches a little about this type of file can pass me too, I gave a brief search but nothing that was significant to solve the problem.

  • What problem? You asked only what he does.

  • 1

    This post talks about the RewriteCond http://answall.com/q/102722/11404

  • Redirecting, when trying to enter a site that is in FTP it recognizes but is redirected to HOME. As I don’t know much about these types of files I’m going from bottom to top, and wondering if the problem might be in this file I passed

  • The link @Jcsaint sent already cleared something, those ! -d and ! -f checks if the directory and file exist, probably they are not being recognized and then redirects to the index, maybe ...

Show 2 more comments

1 answer

1


Briefly the URL rewriting rule says that all requests should go to the index.php file receiving the requests by the parameter path.

In this file index.php will have something like $_GET['path'] or it may be inside a function and not visible in indesx.php.

These rules will apply to the folder /acompanhamentoobra/ which is defined as a basis.

The lines with -f, -d and -l is to ignore the rule if an existing file, directory or symbolic link is accessed, respectively.

The excerpt (\.php)$ is to deviate from. php files in that folder and enter the rewrite condition.

Obs:
But don’t confuse or mix things up. PHP, MVC and htccess are distinct from each other. In the question itself there is nothing MVC or PHP.

htaccess is part of the module mod_rewrite apache.

  • So, even in java for example we can use this . htacess? Since it is a "configuration" of the server, just use apache and it would already work?

  • java? vc refers to java or javascript? or jsp?

  • In this case jsp, I mean, since it’s an apache configuration, it doesn’t matter what language it’s being developed in?

  • There will be some variations. JSP usually runs under Tomcat also from Apache Group. But overall everything works just like Apache httpd

  • OK Daniel, thank you! I’ll work on that now and try to see what the problem is, most likely it’s in that file.

Browser other questions tagged

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