使用 .htaccess 文件的 Web 服务器配置

web server configuration using .htaccess file

当我尝试使用 .htaccess 实现 Web 服务器配置时,它没有将我重定向到指向的文件。我在 httpd.conf 中更改了 "AllowOverride: All" 并检查了 mod-rewrite module 已启用。但是当我尝试 URL "localhost/student-portal/student":

时它会抛出如下错误
  **Internal Server Error** 
  The server encountered an internal error or misconfiguration and was unable to complete 
  your request. Please contact the server administrator at admin@example.com to inform them 
  of the time this error occurred, and the actions you performed just before this error. 
  More information about this error may be available in the server error log.

.htaccess 文件片段

 RewriteEngine on 
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-l

 RewriteRule ^(.*)$ index.php?url= [QSA, L]

index.php

<?php
    $url = $_GET['url'];
    echo '"'.$url.'"'.'is the requested page';
?>

这是我的 error.log 文件:

[Fri Dec 04 13:51:17.923527 2015] [core:alert] [pid 4796:tid 1172] [client ::1:52258] C:/Bitnami/wampstack-5.5.30-0/apache2/htdocs/student-portal/.htaccess: RewriteRule: bad flag delimiters

标志中不允许 space

改变

RewriteRule ^(.*)$ index.php?url= [QSA, L]

RewriteRule (.*) index.php?url= [QSA,L]

^ 表示从 $ 表示结束于

所以当你使用 .* 时,这意味着它们都不需要