How to avoid rewriting redirects?

Asked

Viewed 74 times

1

I have the following rule at the root:

RewriteEngine On

RewriteRule ^webapp/(.*)$  ./sistema/public/v1/webapp/$1 [L,R=301]

The problem is that when I type in the browser: http://projetoxyx.com.br/webapp

He’s redirecting and not rewriting to: http://projetoxyx.com.br/sistema/public/v1/webapp

Vhost:

<VirtualHost *:80>
    ServerAdmin [email protected]
    DocumentRoot "/Users/myuser/projects/projetoxyx"
    ServerName projetoxyx.local   
    ServerAlias www.projetoxyx.local
    ErrorLog "logs/dummy-projetoxyz-error.log"
    CustomLog "logs/dummy-projetoxyz-access.log" common

    setEnv APPLICATION_ENV "development"
    <Directory "/Users/myuser/projects/">
        Options Indexes FollowSymLinks Includes execCGI
        AllowOverride All
        Require all granted
   </Directory>
</VirtualHost>

This is from the system: . /system/public/. htaccess:

RewriteEngine On

    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]

    RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::^B$
    RewriteRule ^(.*)$ - [E=BASE:%1]
    RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

    Options -Indexes

What do you need to do so he doesn’t redirect?

1 answer

1


Removes the R=301, this flag states that it is to redirect 301 according to the documentation https://httpd.apache.org/docs/current/rewrite/flags.html#flag_r, but if you just want to rewrite the url, remove it like this:

RewriteEngine On

RewriteRule ^webapp/(.*)$ ./sistema/public/v1/webapp/$1 [L]

I’m not sure, but I believe ./ is not correct, if sistema/ is at the root the correct would be that only:

RewriteEngine On

RewriteRule ^webapp/(.*)$ /sistema/public/v1/webapp/$1 [L]

Some details on this question: What L, R, NC means in HTACCESS?

Browser other questions tagged

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