views:

102

answers:

2

Is there a way to find out if a server supports mod_rewrite & .htcaccess

+3  A: 

http://us3.php.net/apache_get_modules will output something similar to the following:

Array
(
    [0] => core
    [1] => http_core
    [2] => mod_so
    [3] => sapi_apache2
    [4] => mod_mime
    [5] => mod_rewrite
)

Just look for mod_rewrite. You could even write a small function using in_array() to make it easier to determine whether a given module is loaded or not.

Jonathan Sampson
+1. Your idea is better than mine.
Randolph Potter
This does not show if rewrite rules can be set using a .htaccess
gnud
Good info and worth a vote, but I'm pretty sure that wouldn't tell you if 1. RewriteRules were on for your virtual domain or 2. AllowOverrides were on for your virtual domain.
Alan Storm
+3  A: 

I'd create a test scenario by adding mod_rewrite to .htaccess. There's an example here.

Randolph Potter
To .htaccess thats the only way after all. Many hosts doesn't accept files named ".htaccess" or have AllowOverride disabled.
Havenard