I am coding something and I cannot be bothered to go through the whole of the website again and do a if(modrewrite enabled) thing to display the version depending if its enabled. Maybe when I have a spare 6 hours I will, but I was curious, how many servers fo you think dont have it enabled. I only ask because every server I have ever worked on has had it enabled, but thats because Ive configured them this way. I havent ever rented from anyone for obvious reasons I dont need to.
If you're planning on distributing your script, you'd be very wrong to assume that every server is Apache, let alone with a particular module enabled. Checking the config every time there is a URL that you need to output is going to be very tedious. Have you considered using output buffering and then just a single regex search/replace on all the internal links?
Assuming PHP, example: <?php // At top of script before any output, start buffering ob_start('prettyURLs'); // Define our callback function (prettyURLs) to replace links function prettyURLs($buffer) { global $cfg; if ( ! $cfg->useModRewrite ) $buffer = preg_replace('/a href="\/([^"])"/','a href="index.php?req=\\1',$buffer); return $buffer; } // Do all your normal stuff echo '<a href="/pretty/url/using/mod-rewrite.html">Some link</a>'; // Send the output buffer // See manual but basically everything that has previously // been echo/printed gets passed to our callback function ob_end_flush(); ?> PHP: The manual explains it better than I can, and the regex will probably require a bit more work. Basically you assume either all links are the "pretty URLs" or they're not, and you print them in that format. Then using the ob_ functions, you stop the all output from echo/print being sent straight to the browser until the end of the script (or until you call a flush() function to send it). You can specify a custom callback function that receives the buffer as a variable, and manipulate the output however you want. In this case, you want to use a regular expression to replace your internal links depending on whether or not you want to use mod_rewrite.