开发者

A universal mod-rewrite htaccess file for my script

开发者 https://www.devze.com 2022-12-09 19:14 出处:网络
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.

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 si开发者_Go百科mple 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.


Try this...

RewriteEngine On
# if the file|folder exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)$ /$1/index.php?$2 [L,QSA]
0

精彩评论

暂无评论...
验证码 换一张
取 消