1

我请求了一个网址“http://mydomain/testscripts/php_Env”

我的 testscripts 文件夹中有一个 php_Env.php 文件。

我的htaccess如下

RewriteEngine On    # Turn on the rewriting engine
RewriteCond %{REQUEST_FILENAME} !-f    # Existing File
RewriteCond %{REQUEST_FILENAME} !-d    # Existing Directory
RewriteRule    ^(php_([a-zA-Z_]+))$  $1.php   [NC,L]

运行时,浏览器返回我

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log

我想要做的是,如果请求文件不是目录而不是文件,则请求文件。我在 htaccess 中哪里出错了?

4

1 回答 1

1

尝试没有多余的空格和注释:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(php_([a-zA-Z_]+))$ $1.php [NC,L]

如果可行,您可以添加回注释(可能在规则中的最后一个字符和#符号之间只留一个空格)。

于 2012-05-31T07:00:58.290 回答