Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use to following rewrite rule to pass the whole url to an php script:

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*?)$ index.php?rewriteUrl=$1 [QSA,L]

On some servers, I have to use

RewriteRule ^(.*)$ index.php?rewriteUrl=$1 [QSA,L]

instead (the ? is missing).

Is there a way to make the server handle this automatically? In form of a fallback/try-catch or something like this?

share|improve this question
    
I can't say I understand your question or the point of having the ? in the expression. For information on regular expression usage in mod_rewrite, please see the Apache documentation. – qsheets Nov 1 '12 at 16:53

If you know the different version numbers between the two servers, use mod_version to do this. For instance, if 2.3+ uses the ?:

<IfVersion >= 2.3>
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*?)$ index.php?rewriteUrl=$1 [QSA,L]
</IfVersion>

<IfVersion < 2.3>
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?rewriteUrl=$1 [QSA,L]        
</IfVersion>

Use ServerSignature to have the version info sent to the client.

share|improve this answer

You must log in to answer this question.

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