我正在编写一个(我希望)将被广泛分发的脚本,并且我希望确保它能够开箱即用地在尽可能多的服务器上运行。
这个脚本需要一个 .htaccess 文件,但我了解到一些 htaccess 文件不是很便携。
htaccess 需要做一个简单的重定向,像这样:
http://example.com/dir/string
Redirect to...
http://example.com/dir/index.php?string
“通用”.htaccess 文件应该是什么样子才能在所有 Windows 和 Linux 服务器上运行。
最佳答案
试试这个...
RewriteEngine On
# if the file|folder exists
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/(.*)$ /$1/index.php?$2 [L,QSA]
关于windows - 用于我的脚本的通用 mod-rewrite htaccess 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1611381/