Where is my error? RewriteCond or Rule?

ISAPI_Rewrite is Apache mod_rewrite compatible URL rewriter for Microsoft IIS
User avatar
Posts: 8
Joined: 08 Apr 2012, 18:14

Where is my error? RewriteCond or Rule?

03 May 2012, 00:37

Can anyone help me?

Code: Select all
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=(.*)$ [NC]
RewriteRule ^eventos/informacao\.asp$ /eventos/%1 [NC,R=301,L]


Url is
http://www.mysite.com.br/eventos/informacao.asp?id=paula_fernandes_em_pocos_de_caldas_18052012
Result is
http://www.mysite.com.br/eventos/paula_fernandes_em_pocos_de_caldas_18052012?id=paula_fernandes_em_pocos_de_caldas_18052012

I need this
http://www.mysite.com.br/eventos/paula_fernandes_em_pocos_de_caldas_18052012

Can anyone give me a hint, already tried and tested several, but not working.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Where is my error? RewriteCond or Rule?

03 May 2012, 06:50

Hello,

there's a tiny trick for this, you need to use '?' at the end of the rule to avoid appending querystring:

Code: Select all
RewriteEngine on
RewriteCond %{QUERY_STRING} ^id=(.*)$ [NC]
RewriteRule ^eventos/informacao\.asp$ /eventos/%1? [NC,R=301,L]


Regards
Andrew

User avatar
Posts: 8
Joined: 08 Apr 2012, 18:14

Re: Where is my error? RewriteCond or Rule?

03 May 2012, 17:56

ran the url was written
http://www.mysite.com.br/eventos/paula_fernandes_em_pocos_de_caldas_18052012

the problem is found the page
The system can not find the file specified.
have any tips on that?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Where is my error? RewriteCond or Rule?

04 May 2012, 06:01

Well, you wanted a redirect. the rule works fine you get redirected.
Maybe now you need a rewrite rule to load the content for SEO friendly URL?

Regards
Andrew

User avatar
Posts: 8
Joined: 08 Apr 2012, 18:14

Re: Where is my error? RewriteCond or Rule?

05 May 2012, 03:40

I found after much research, a provisional solution.
She is working but not as I wanted.
I had to rename Eventos to Evento
As I had to do for him to apply this rule, only the file informacao.asp?
Code: Select all
RewriteCond %{QUERY_STRING} ^id=(.*)$ [NC]
RewriteRule ^eventos/informacao\.asp$ /evento/%1? [NC,R=301,L]
RewriteRule ^evento/([^/]+)$ /eventos/informacao.asp?id=$1 [NC,L]


I think it is something in this part ([^/]+)$

This is my code that should work
Code: Select all
RewriteCond %{QUERY_STRING} ^id=(.*)$ [NC]
RewriteRule ^eventos/informacao\.asp$ /eventos/%1? [NC,R=301,L]
RewriteRule ^eventos/([^/]+)$ /eventos/informacao.asp?id=$1 [NC,L]


Could someone help me with this? Please.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: Where is my error? RewriteCond or Rule?

07 May 2012, 06:52

Please, provide rewrite.log for the testing request.
Logging issues described in FAQ

Regards
Andrew

Return to ISAPI_Rewrite 3.0

Who is online

Users browsing this forum: No registered users and 7 guests