Forum Moderators: phranque

Message Too Old, No Replies

Is this the correct rewrite

mod rewrite rule

         

web79

4:20 pm on Apr 18, 2009 (gmt 0)

10+ Year Member



I have a number of urls on my site duplicated by the userid. Pages are indexed like this

mysite.com/widgets/blue.php?UID=
mysite.com/widgets/blue.php
mysite.com/widgets/blue.php?UID=24

I would like each of them to revert back to the .php. I am also in the process of having my site redesigned and as such the new url will be mysite.com/widgets/blue/

I have been searching and testing different rules for the last three days and haven't been able to find one which works the way I need.

Is this right or am I just doing it wrong.

RewriteEngine On
RewriteCond %{QUERY_STRING} ^UID=([0-9]*)$
RewriteRule ^/widgets\blue\.php$ [mydomain.site...] [R=301,L]

Any help would be appreciated. I have tried to understand the main page here which explains the mod rewrites as well as read through multiple articles to get this to work and it's just not happening.

Thank you in advance

g1smd

6:16 pm on Apr 18, 2009 (gmt 0)

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



You need more than one rule here.

You'll need at least two redirects and one rewrite.

Be aware that RewriteRule, when used in .htaccess, cannot 'see' the leading slash on the requested URL.

You also have a \ where a / should be, in your pattern.

However, when those are corrected, your rule will not do what your example says you require it to do.

That is, a URL request with

UID=
and no number in it, will be 301 redirected to
http://example.com/widgets/blu[b]e/.p[/b]hp
for example.

g1smd

7:51 pm on Apr 18, 2009 (gmt 0)

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



The title of this thread mentions a "rewrite" but your example code is for a "redirect".

Be clear as to the differences between a redirect and a rewrite and the coding differences to make each one work.