URL rewriting in . htaccess

Asked

Viewed 201 times

3

have the following URL:

http://<site>/application/views/ambiente_teste/assets-teste/...

And I wanted to rewrite it for:

http://<site>/assets-teste/...

I have tried in my . htaccess the following:

RewriteRule ^assets-teste/?$ /application/views/ambiente_teste/assets-teste [NC,L]

But I’m not very experienced at it, so I was wondering if anyone had a solution.

Thanks ^^

  • 3

    ReweiteRule should be RewriteRule. Will that?

  • 1

    Your URL does not start with Assets-test, then remove this circumflex that the expression starts to marry only backwards and, unless mistaken, will work.

  • @Zuul, that was typo here hehe.

  • @Brunoaugusto, solved my problem Thank you very much to both, I am new user, because I did not find the answer I needed, if you want to teach me to give a few points to you in thanks I accept. Thanks :)

  • 1

    @Luizfilipemachadobarni You accepted an answer but it does not meet the solution that Bruno stressed and you say have solved your problem :/

  • 1

    @Brunoaugusto Put an answer with your solution as it has solved the problem.

  • @Zuul is right, I edited the answer to make sense, but it would be nice to have Bruno’s

Show 2 more comments

2 answers

3


This will be an express response ^_^

Your URL does not start with Assets-test, then take off that circumflex that the expression happens to marry only backwards and then it will work:

RewriteEngine On
RewriteRule assets-teste/?$ /application/views/ambiente_teste/assets-teste/ [NC,L]
  • solved my problem, but if I proceed to a subsequent directory, ex:/assets-teste/css/ I have a 404 page. So at the end I’m still in trouble :(

  • 1

    That’s another problem. But try to change the ER question for (\w+) and there in the real URL, before the flags, put $1, representing the content captured by the group (parentheses).

0

# Ativamos a reescrita
RewriteEngine On
RewriteBase /

# Alterar URL
RewriteRule ^assets-teste /application/views/ambiente_teste/assets-teste/ [NC,QSA,L]

Browser other questions tagged

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