I want to take a shot at writing an Apache RewriteMap in PHP.
The example they give is in perl, which I don't know.

The perl example is here

I'm not going to do anything to ambitious, but they do give a warning that
if you get it wrong you hang the server, so I was hoping someone can point me at a simple example of such a module in PHP, or give me a few pointers as to potential pitfalls. Or if anyone knows perl point me to the PHP equivalence.

Otherwise I'm going to have to learn a bit of perl ( which I really don't want to do ).



Recommended Answers

All 3 Replies

There is a pretty good tutorial here. There is also a tutorial here on Daniweb at this link that deals with rewriting for vbulletin. I haven't read the tutorial here on Daniweb, but I'm sure there are lots of questions and answers that may be helpful as it is a huge thread. I also assume you have had a look at the Apache URL Rewriting Guide, I found it very hard to follow :o Understand that you really aren't doing anything in PHP, you will be creating commands that the apache server interprets and executes itself.

Good luck.


Actually I'm pretty close to cracking this one.

Not sure what you mean about "not doing anything in PHP" tho. I've written the Rewrite rules in PHP and made it into a shell script which Apache will read when it does a RewriteRule in .htaccess

I think it's near to working, only think I can't quite figure is the correct syntax for the rewrite rule.

Currently I have

RewriteRule \.(wmv)$ $(nohotlink:$1)

where nohotlink is the name of my map.

I want to feed all files of type .wmv into my RewriteMap ( which is the PHP bit ). I'll go look at the tutorials now.

Thanks for the tip!

OK solved!

It was so late at night I didn't notice the ( and ) were { and }

RewriteEngine On
RewriteRule \.(wmv)$ ${nohotlink:$1}

does the trick.

thanks all

I've been developing PHP for a few months now, and I like it. It's pretty easy and I've never really got stuck on anything, but it's nice to find a board to post to. I'll try to come back and maybe answer a few questions as well as ask em.

have a nice day!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.