19

The mod_rewrite tag is one of the most affected by a maddening constant stream of quasi-duplicates.

They always look like this (Translated:)

I have a URL /mypage/index.php?page=1&place=New+York

I want it to look like this: /mypage/1/New+York

How to do it?

I do not understand mod_rewrite, nor do I want to learn how it works. I just want my site to work with those URLs. Please send me the codes.

now, I just found out that the folks over on Server Fault have started building a great reference question for this: Everything You Ever Wanted to Know about Mod_Rewrite Rules but Were Afraid to Ask?

The question and the answers therein are of excellent reference quality, and I would find it fitting to close incoming mod_rewrite questions as a duplicate of this one on SO as well.

The problem is obviously, it is on a different site. What to do?

  • Copy the question over to SO and ask all contributors to add their content there as well - feels unnatural

  • Start a question on SO and point to the Serverfault one - feels unnatural

  • Start migrating mod_rewrite questions to Serverfault - against established policy, although for this, I would agree to changing the policy

Any better ideas?

2 Answers 2

3

Let's have our own reference question.

The article on serverfault is a formidable effort. However it's too lengthy and high-level. The particular kind of mod_rewrite asker we have on SO will not bother to read through it. Sending them there is appropriate, but not a solution. (Though I'm generalizing from yesterdays incident.)

We need to prepare an answer specific to our ass-lazy php coderz. Examples first, explanation later. Btw, I am just the messenger.

Since Stackoverflow already has this instant-redirect feature for offtopic questions, it doesn't matter if we create a temporary reference question. The answer on serverfault is quite new, will surely improve, and we can decide later to abandon our reference question in favor of a permanent redirect. [admin advise needed]
Until then, I'd advise to do it Wikipedia-style with an unstylish info box:

Dear reader, this is a collection of common examples and short explanations for mod_rewrite. For further reading we recommend: https://serverfault.com/questions/214512/everything-you-ever-wanted-to-know-about-mod-rewrite-rules-but-were-afraid-to-ask Oh and btw, Apache also has a manual...

Needs better wording. And I'm also not quite convinced if it's worth the effort to maintain a similar tutorial twice. OTOH having a duplicate to answer duplicates sounds plausible, and I do believe we need something specific to the more problematic PHP species.

2
  • 2
    PS: As suggested last week, we might need a regex reference question first. (Because regex /i+llite{1}r[ac]*y/ contributes to RewriteRule nagging.)
    – mario
    Jan 3, 2011 at 3:45
  • Good points as well, and the idea of using the new instant redirect later is sneaky! I like it.
    – Pekka
    Jan 3, 2011 at 10:40
12

Trying to maintain the same tutorial on two sites is madness. That's what linking is for.

If a question is a duplicate of one on another site, then it makes perfect sense to migrate it (and then close it).

But there's no point in closing "Plz send me teh codez" questions as duplicates of anything apart from questions asking for the exact same "codez". The folks asking these don't want to learn, or they'd have spent half an hour with one of the countless online mod_rewrite / jQuery / basic mathematics tutorials and already solved their own problem.

If someone wants to spend their days giving the men fish, let 'em. If you feel generous, post a link to the SF question in comments.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .