Lets try something basic to begin with.
in the bottom of your httpd.conf (under apache install dir /conf)
add these lines:
RewriteEngine on
RewriteRule ^/test/(.*)\.html$ /artist.php?id=$1 [PT,L]
Save and reload the httpd server.
Then try testing it by going to a browser and typing in www.mysite.com/test/x.html
(where x is the value to send to id)
Let us know if that works. Then we can discuss more puzzle like configurations.
Olaf
In my local server (iBook, OS X, Apache, PHP 4.2 & MySQL) I get an Error 404 (1.html not found).
In my production server (OpenBSD) I get an error when restarting Apache, I checked the httpd.conf file and there's no mod_rewrite installed, hehe, so I'll install mod_rewrite, try the test and tell you the results.
Meanwhile, in my local server, why do you think I get an Error 404?
Maybe mod_rewrite is not working? How can I make sure it is loaded and working?
you can test the mod_rewrite with even more basic examples.
If mod_rewrite is working this definetly should work
RewriteEngine on
RewriteRule ^/test/123\.html$ /artist.php?id=123 [PT,L]
Here we have just hard coded the url www.mysite.com/test/123.html to the base /artist.php?id=123
Check your apache error log. If it says something to the effect "file /webroot/test/123.html not found" Then its ignoring the rewrite rule and looking for a flat file. (Are you sure that you're adding to the correct httpd.conf? (I have to ask) :) )
Olaf
The only tricky thing is that if you want the base to be www.domain.com/artist.html
Then we are rewriting all the document root references. Which will mean that someone typing in www.domain.com/index.html will be sent to the server as /artist.php?id=index (grabbing the index in index.html)
That can be cirumvented by creating a special rewriterule to grab all your static files. (which means one rewrite rule line for each static page you want) This is pretty cumbersome and doesnt scale very well.
So using a "dynamic virtual folder" usually does the trick. Such as saying that the every file requested in the folder /artist/ should be rewritten to artist.php?id=xxx
(you decide what folder name you would like to have)
Now, by going to the original rewrite lines I put in here :
RewriteEngine on
RewriteRule ^/artist/(.*)\.html$ /artist.php?id=$1 [PT,L]
This should grab anyone accessing www.domain.com/artist/123.html and send it to /artist.php?id=123 without the user being the wiser (PT stands for PassThrough, ie. the rewriteengine works as a hidden proxy for your script and L stands for Last, stops looking for rewrite directives after matching)
Now when this line is in your httpd.conf and you have restarted your webserver, try accessing www.domain.com/artist/123.html
A good thing to do while testing this is to have a "tail -f" on both your apache error.log and and the weblog
f.i. one telnet/ssh window do a "tail -f error_log" and on another "tail -f combined_log"
(or whatever you have your logging filenames set to)
This should work.
If not show us what your where getting in the error log or access log
I for instance, am running a webserver where every single access point is a script. (except for the base /index.html and the 404 file)
And to make my life easier I have the script names in my language and with a very descriptive naming method. Such as. prc_guestbook_archive and can refer to them as prc_guestbook_archive?page=40&lang=en&entr_p_page=10
But none of that ever gets seen by the user visiting my webpage. He just sees the rewrite name. So that when he clicks the guestbook link he is accessing /path/guestbook.html which looks perfectly normal to him.
It also allows me to develope new versions of scripts and test them. And instead of replacing the original script I just modify the rewrite entry and point it to the new script name.
Many thanks in advance
Joe