Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.