Simple rewrite URL with parameters not working
6 posts
• Page 1 of 1
- federico.botto
- Posts: 5
- Joined: 14 Mar 2014, 10:22
Simple rewrite URL with parameters not working
Hello,
I have this url: http://localhost/bgh/Hogar_Personas_Cocina?ID=3 (Original)
And i'm trying to reach something like http://localhost/bgh/Cocina/3 (Rewrited)
RewriteRule ^Cocina/([0-9]+)/?$ Hogar_Personas_Cocina.aspx?ID=$1 [NC,L]
But when i browse the original, it's never rewrited.
I can say that the rewriting it is working because the original url should have the extension and by ISAPI is beeing hidded.
Thanks in advance!
I have this url: http://localhost/bgh/Hogar_Personas_Cocina?ID=3 (Original)
And i'm trying to reach something like http://localhost/bgh/Cocina/3 (Rewrited)
RewriteRule ^Cocina/([0-9]+)/?$ Hogar_Personas_Cocina.aspx?ID=$1 [NC,L]
But when i browse the original, it's never rewrited.
I can say that the rewriting it is working because the original url should have the extension and by ISAPI is beeing hidded.
Thanks in advance!
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Simple rewrite URL with parameters not working
Hello,
You're doing the opposite to what you want. Try using:
Regards
You're doing the opposite to what you want. Try using:
- Code: Select all
RewriteCond %{QUERY_STRING} ^ID=(\d+)$ [NC]
RewriteRule ^bgh/Hogar_Personas_Cocina /Cocina/%1? [NC,R=301,L]
Regards
- federico.botto
- Posts: 5
- Joined: 14 Mar 2014, 10:22
Re: Simple rewrite URL with parameters not working
Hi Andrew, thanks for your reply.
If use exactly as you said, the redirect isn't working.
The original is: http://localhost/bgh/Hogar_Personas_Cocina?ID=3
If i change your script to:
RewriteCond %{QUERY_STRING} ^ID=(\d+)$ [NC]
RewriteRule ^Hogar_Personas_Cocina Cocina/%1? [NC,R=301,L]
Removing de bgh/ and the strating / from Cocina, it redirects to http://localhost/bgh/Cocina/3, as i need, but a Page not found is beeing displayed.
If it helps, the original page, has the base tag.
Thanks for your help!
Regards
If use exactly as you said, the redirect isn't working.
The original is: http://localhost/bgh/Hogar_Personas_Cocina?ID=3
If i change your script to:
RewriteCond %{QUERY_STRING} ^ID=(\d+)$ [NC]
RewriteRule ^Hogar_Personas_Cocina Cocina/%1? [NC,R=301,L]
Removing de bgh/ and the strating / from Cocina, it redirects to http://localhost/bgh/Cocina/3, as i need, but a Page not found is beeing displayed.
If it helps, the original page, has the base tag.
Thanks for your help!
Regards
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Simple rewrite URL with parameters not working
It helps a lot. The base tag does it all.
Now you have a 301-redirect which only changes the URL in a browser. All you need is to add your rule to load the content from an old location.
Regards
Now you have a 301-redirect which only changes the URL in a browser. All you need is to add your rule to load the content from an old location.
Regards
- federico.botto
- Posts: 5
- Joined: 14 Mar 2014, 10:22
Re: Simple rewrite URL with parameters not working
Thanks, and that rule would be, how?
Thanks in advance
Thanks in advance
- HeliconAndrew
- Posts: 1264
- Joined: 07 Mar 2012, 10:16
Re: Simple rewrite URL with parameters not working
The rule you provided. YOu need both:
Regards
- Code: Select all
RewriteRule ^Cocina/([0-9]+)/?$ Hogar_Personas_Cocina.aspx?ID=$1 [NC,L]
RewriteCond %{QUERY_STRING} ^ID=(\d+)$ [NC]
RewriteRule ^Hogar_Personas_Cocina Cocina/%1? [NC,R=301,L]
Regards
6 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests