Forum Moderators: phranque

Message Too Old, No Replies

Hello, I need help with mod rewrite

         

dav63

9:26 am on Jul 25, 2011 (gmt 0)

10+ Year Member



Hello everybody, I have joined this forum today.

I need help on this issue:

with htaccess mod rewrite I need to change the following addresses (corresponding to the same web site page originated by a CMS software):

www.site.com/bin/index.php?id=1200
www.site.com/bin/index.php?id=page-name

into

www.site.com/bin/page-name.html

In htaccess I have wrote the following:

Options +FollowSymLinks
RewriteEngine On

RewriteCond %{QUERY_STRING} ^id=1200$ [OR]
RewriteCond %{QUERY_STRING} ^id=page-name$
RewriteRule ^bin/index.php$ [site.com...] [L,R=301]

Unfortunately I get Error 310 (net::ERR_TOO_MANY_REDIRECTS) too many redirects

Appreciate for the help

dav63

11:35 am on Jul 25, 2011 (gmt 0)

10+ Year Member



I forgot a line, my htaccess is:

Options +FollowSymLinks
RewriteEngine On

RewriteRule ^bin/([^/]+).html$ /bin/index.php?id=$1 [L]

RewriteCond %{QUERY_STRING} ^id=1200$ [OR]
RewriteCond %{QUERY_STRING} ^id=page-name$
RewriteRule ^bin/index.php$ [site.com...] [L,R=301]

Please someboy can help me?

lucy24

4:27 pm on Jul 25, 2011 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



RewriteRule ^bin/index.php$ http://www.example.com/page-name.html? [L,R=301]

See the question mark at the end of the target? That means "get rid of the existing query string". By default

:: y'know, I swear I've said this three times in the past 24 hours ::

By default, rewrites don't touch the query string at all, they just quietly reappend it. That's why you're getting an infinitude of rewrites. You have to get rid of the query string. You do that by attaching a question mark to the target. Technically it means "replace the existing query with whatever comes after the question mark" -- in this case, nothing.

dav63

6:30 pm on Jul 25, 2011 (gmt 0)

10+ Year Member



Many thanks for the reply lucy