Query string Shows in URL After redirect

New to mod_rewrite? This is a good place to start.

Query string Shows in URL After redirect

Postby Victor » Tue Oct 20, 2009 7:58 am

Ok, my question is a bit convoluted, but I'll try my best to explain.

I have rewritten most of the urls on the site.

Here are my rewritten urls:
Code: Select all
Rewriterule ^generalpower_parts/(.+)/(.+)/(.+).html producto_partes.php?categoria=$1&id_tienda_producto=$2&title=$3

Rewriterule ^powergeneral/(.+)/(.+).html lista_productosN.php?id_tienda_categoria=$1&categoria=$2



However, now I have to redirect certain pages to new pages. Here is my redirect:

Code: Select all
Redirect 301 /generalpower_parts/automatic-voltage-regulators/353/newage-automatic-voltage-regulators-avr.html http://www.dieselgeneratorsmiami.com/powergeneral/28/newage-avr.html


the result is this link with the query string after it:

Code: Select all
http://www.dieselgeneratorsmiami.com/powergeneral/28/newage-avr.html?categoria=automatic-voltage-regulators&id_tienda_producto=353&title=newage-automatic-voltage-regulators-avr


Any help will be really appreciated, thanks.
Victor
 
Posts: 2
Joined: Tue Oct 20, 2009 6:54 am

Postby richardk » Tue Oct 20, 2009 9:22 am

So the redirect with mod_rewrite
Code: Select all
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^generalpower_parts/automatic-voltage-regulators/353/newage-automatic-voltage-regulators-avr\.html$ /powergeneral/28/newage-avr.html? [R=301,L]

RewriteRule ^generalpower_parts/(.+)/([0-9]+)/(.+)\.html$ producto_partes.php?categoria=$1&id_tienda_producto=$2&title=$3 [QSA,L]

RewriteRule ^powergeneral/([0-9]+)/(.+)\.html$ lista_productosN.php?id_tienda_categoria=$1&categoria=$2 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby Victor » Tue Oct 20, 2009 11:21 am

hmm, it doesn't redirect now. I just took over this site and am trying to straighten out the url situation. Here is my complete htaccess as it stands now. I know the formatting is not uniform, could that be causing some conflict?

Code: Select all
Options +FollowSymLinks
RewriteEngine on

RewriteCond %{HTTP_HOST} ^dieselgeneratorsmiami.com
RewriteRule (.*) http://www.dieselgeneratorsmiami.com/$1 [R=301]
RewriteCond %{THE_REQUEST} index\.php
RewriteRule ^index\.php http://www.dieselgeneratorsmiami.com/ [R=301]


RewriteRule ^generators-page-(.*)-hz-(.*)-ph-(.*)-kwi-(.*)-kwf-(.*)\.html$ /productos_FC.php?pageNum_porductos_fil=$1&hz=$2&ph=$3&kwi=$4&kwf=$5
RewriteRule ^generators-hz-(.*)-ph-(.*)-kwi-(.*)-kwf-(.*)\.html$ productos_FC.php?hz=$1&ph=$2&kwi=$3&kwf=$4
Rewriterule ^powergenerators/(.+)/(.+) contenidos.php?Id_Categoria=$1&title=$2
Rewriterule ^generalpower/(.+)/(.+)/(.+).html producto.php?categoria=$1&id_tienda_producto=$2&title=$3
RewriteRule ^generalpower_parts/(.+)/([0-9]+)/(.+)\.html$ producto_partes.php?categoria=$1&id_tienda_producto=$2&title=$3 [QSA,L]
RewriteRule ^powergeneral/([0-9]+)/(.+)\.html$ lista_productosN.php?id_tienda_categoria=$1&categoria=$2 [QSA,L]
Rewriterule ^powergeneralpages/(.+)/(.+)/(.+).html lista_productosN.php?pageNum_lista_productos=$1&id_tienda_categoria=$2&categoria=$3
RewriteRule ^news-(.*)\.html$ noticias_detalle.php?Id_Noticia=$1

RewriteRule ^generalpower_parts/automatic-voltage-regulators/353/newage-automatic-voltage-regulators-avr\.html$/powergeneral/28/newage-avr.html? [R=301,L]
ErrorDocument 404 /404.php
Victor
 
Posts: 2
Joined: Tue Oct 20, 2009 6:54 am

Postby richardk » Wed Oct 21, 2009 10:11 am

You have to put the redirects first.
Code: Select all
ErrorDocument 404 /404.php
Options +FollowSymLinks

RewriteEngine On

RewriteRule ^generalpower_parts/automatic-voltage-regulators/353/newage-automatic-voltage-regulators-avr\.html$ http://www.example.com/powergeneral/28/newage-avr.html? [R=301,L]

RewriteCond %{THE_REQUEST} \ /(.+/)?index\.php(\?.*)?\  [NC]
RewriteRule ^(.+/)?index\.php$ http://www.example.com/%1 [NC,R=301,L]

RewriteCond %{HTTP_HOST} ^(example\.com)$ [NC]
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]

RewriteRule ^generators-page-(.*)-hz-(.*)-ph-(.*)-kwi-(.*)-kwf-(.*)\.html$ /productos_FC.php?pageNum_porductos_fil=$1&hz=$2&ph=$3&kwi=$4&kwf=$5 [QSA,L]
RewriteRule ^generators-hz-(.*)-ph-(.*)-kwi-(.*)-kwf-(.*)\.html$ productos_FC.php?hz=$1&ph=$2&kwi=$3&kwf=$4 [QSA,L]
Rewriterule ^powergenerators/(.+)/(.+) contenidos.php?Id_Categoria=$1&title=$2 [QSA,L]
Rewriterule ^generalpower/(.+)/(.+)/(.+).html producto.php?categoria=$1&id_tienda_producto=$2&title=$3 [QSA,L]
RewriteRule ^generalpower_parts/(.+)/([0-9]+)/(.+)\.html$ producto_partes.php?categoria=$1&id_tienda_producto=$2&title=$3 [QSA,L]
RewriteRule ^powergeneral/([0-9]+)/(.+)\.html$ lista_productosN.php?id_tienda_categoria=$1&categoria=$2 [QSA,L]
Rewriterule ^powergeneralpages/(.+)/(.+)/(.+).html lista_productosN.php?pageNum_lista_productos=$1&id_tienda_categoria=$2&categoria=$3 [QSA,L]
RewriteRule ^news-(.+)\.html$ noticias_detalle.php?Id_Noticia=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Beginner's Corner

Who is online

Users browsing this forum: Google [Bot] and 27 guests

cron