Interception and redirection

Asked

Viewed 66 times

0

My structure

localhost/sistema
localhost/sistema/.htaccess
localhost/sistema/site/index.php

Goal: When accessing any url within the domínio occur to interceptação and the redirecionamento to the page index.php that’s in the directory localhost/system/website

attempt on . htaccess

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -t [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.$ - [NC,L]
RewriteRule ^.$ site/index.php [NC,L]

Upshot.

Erro 500

Where am I going wrong?

Observing:

Row

LoadModule rewrite_module modules/mod_rewrite.so

uncommented in the httpd.conf

and,

DocumentRoot "C:\Program Files\Apache24\Apache24/htdocs"
<Directory "C:\Program Files\Apache24\Apache24/htdocs">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

Apache log error:

htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration

However, the .so is in the folder

  • What the line RewriteRule ^.$ - [NC,L] ago?

  • picks up the requisitions from the root

2 answers

0

use something simpler , works for what I need here , tests there

RewriteEngine On
# pasta base de referencia
RewriteBase /app
# Proteje pastas de serem acessadas diretamente
RewriteRule ^(classes|includes|logs) - [F,L]
# arquivo que pode abrir diretamente
RewriteCond %{REQUEST_URI} !(homologa.*.php)$
# qualquer outro arquivo e redirecionado para o index.php
RewriteRule . index.php
  • So, just putting Rewriteengine On already gives the error 500

  • you may not have compiled apache with the rewrite module, if you have access to the prompt type the command: apachectl -t -D DUMP_MODULES | grep rewrite_module , check whether the rewrite module appears

0

Although it was a solution that I do not approve of. But what is to be done.

There must be a recourse to it. But we’ll know soon.

The solution is:

<Directory />
    AllowOverride All
    #Require all alowed
</Directory>

That is, change for the whole Apache and not just for the localhost as the line below suggests

DocumentRoot "C:\Program Files\Apache24\Apache24/htdocs"
<Directory "C:\Program Files\Apache24\Apache24/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.4/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #

    #
    # Controls who can get stuff from this server.
    #
    AllowOverride All
    Order allow,deny
    Allow from All
</Directory>

Browser other questions tagged

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