Hi I am trying to set up the free searchbox that Shawn supplies here on my site and would like to mod rewrite the URL's of the results search pages. I have made a .htaccess file for the directory the search results. php file is in, and have added these lines RewriteEngine On RewriteRule bluewidgets results.php?q=blue+widgets Code (markup): But it doesn't work, any suggestions on what I am doing wrong? Many thanks
The pattern in RewriteRule has to cover the entire URL (minus the base path of the resource). For example: RewriteRule ^bluewidgets/$ results.php?q=blue+widgets Code (markup): J.D.
Sorry, I should've been more specific - that is, was there a slash when you made a test request? What you can do, if you have control over the server configuration, is to enable rewrite loging and see if this gives you any additional info to go on. Add these lines in your httpd.conf file (they work at the server or virtual host level; your file path may be different): RewriteEngine on RewriteLogLevel 3 RewriteLog /usr/local/apache2/logs/rewrite_log Code (markup): J.D.
yep laid it out the same as you put it Sorry you lost me there, don't think I am able to do that, I think I don't have access to that file. Don't know if this helps but I already have a rewrite working in another directory with it's own htaccess file, it looks like this RewriteEngine On RewriteBase / RewriteRule ^uk-1/([A-Z0-9]+)\.html$ /widgets/free1.php?asin=$1 [L] Code (markup): and works fine in that application, I didn't write this though, it came with a program I use. Thanks for the help BTW EDIT Tried that configuration which is basically the same and it didn't work either
I asked because I forgot to make the slash optional, so it will work only with a slash in the request. Add a question mark after the slash in the pattern to make it optional (i.e. ^bluewidgets/?$). If there are other rewrite directives in this file matching bluewidgets, check if any of them have [L] (this means that it's the last rule). The bottom line is that it seems that this rule isn't being processed. In general, even your initial line should work, except that it will match any URL that contains the sequence of charaters bluewidgets (which is why it isn't a good idea to use it in this way; e.g. it will match /store/greatbluewidgets/). J.D.
No there are no others matching "bluewidgets" and the other example I quoted is in a completely different directory with its own htaccess file. So why do you think the other URLs are being rewritten OK and the ones in this directory are not? Could one be interfering with the other?
The only thing I can think of is that if you have some rule with [L] that matches bluewidgets (it doesn't have to be bluewidgets - can be just ^.*$). You need to make sure that rewrite rules in this particular .htaccess work (you may have some working rules that prove this, or you can add a catch-all rule at the beginning of the file, similar to the one above, and see if it is being processed). Once you confirmed that rewrite rules in this file are being processed, it's just down to their order/syntax. J.D.
if your .htaccess file is working in a different directory and not in this one... it's possible that the "FileInfo" override is only set in the working directory, and not in the broken one - meaning that you can do rewrites in one place but not in another. If the .htaccess file is working in your root directory, you can ignore this comment. Is this the only thing in your .htaccess file? Can you copy/paste the entire thing here (as it is now) so we can see it and try it out to help you?
Ok Did a bit of a test, moved all the files into my root directory and placed the rewrite rule in my root htaccess above all the other rules so this was the first. Still didn't work! but all the others did, so all I can imagine is that maybe the searchbox works through shawns servers and so bypasses my htaccess instructions. What do you think?