views:

127

answers:

1

I'm writing a script that (I hope) will be widely distributed and I want make sure that it will work on as many servers as possible out of the box.

This script will require an .htaccess file but I've learned some htaccess files are not very portable.

The htaccess needs to do a simple redirect, like so:

http://example.com/dir/string

Redirect to...

http://example.com/dir/index.php?string

What would a 'universal' .htaccess file look like that would work on all windows and linux servers.

A: 

Try this...

RewriteEngine On
# if the file|folder exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)$ /$1/index.php?$2 [L,QSA]
Gabriel Sosa
I tested this and it didn't work.
Chad
I'm running LAMP with WampServer
Chad
are you sure you have the mod_rewrite correctly installed?
Gabriel Sosa
I changed it a bit based on my currently working file and I fixed it. Now will this also work on windows servers?
Chad
since you are working with apache it should be transparent for you. but you dont loose nothing just testing it. And if this was helpful for you please accept the answer :)
Gabriel Sosa