[svlug] gotten myself in trouble with permalinks,

Tin Le tin at le.org
Sun Mar 26 22:25:34 PST 2006


An interesting problem it is.

> Thanks for everyones help.  I'm not quite there yet.  (though just a
> little smarter on reg. exp.  I did download the tool and it appears
> [?]p=24 matches ?p=24 so with that in mind I'm trying to get this:
>
> http://test.cyclohamster.com/?p24
>
> to redirect to
>
> http://test.cyclohamster.com/xxx/bearflag.jpg
>
> I created a one line .htaccess file (after reading
> http://www.sitepoint.com/print/guide-url-rewriting
> 
>
> RewriteRule [?]p24 /xxx/bearflag.jpg

It's not going to work.  You are running into basic HTTP specs.  The ?p24 
or ?p=24 part is the QUERY_STRING part of a GET.  Specifically, it is not 
consider a part of the URI.  The URI is http://test.cyclohamster.com/ and 
the QUERY is ?p24.

Soooo... to make a long story short.

RewriteCond %{QUERY_STRING} ^p=24
RewriteRule ^.*$ /bearflag.jpg [R]

Those two lines is the basic rewrite recipe.  You will need to add salt, 
pepper and water to taste.

If you want a generic "p=SomeNumber", then it is something like this.

RewriteCond %{QUERY_STRING} ^p=\d+
RewriteRule ^.*$ /bearflag.jpg [R]

The only oddity I've noticed is that the recipe works fine _IN_ the server 
httpd.conf, but does not work for me in .htaccess.  I played with it for a 
bit, but don't feel like spending a lot of time on making .htaccess work. 
I put in a lot of time taking them out of my site... so kinda waste of 
effort to make them work again!

Cheers,
Tin Le
-- 
http://tin.le.org
Tin Le - tin at le.org
Firewall and Security Consulting





More information about the svlug mailing list