我有以下内容:
C:\wamp\www\MyProject
,目录结构如下:
MyProject
folder1
folder2
index.php
.htaccess
htaccess
文件包含:
# Turn on mod_rewrite handling
RewriteEngine On
# Allows for three wildcards: page, action and id
RewriteRule (.*?)/(.*?)/(.*?)$
index.php?page=$1&action=$2&id=$3
每当我尝试到达http:\\127.0.0.1/MyProject/testpage/testaction/testid
时,我都会收到以下错误:
Internal Server Error The server encountered an internal error or misconfiguration and was unable tocomplete your request.
我在这里做错了什么?
答案 0 :(得分:0)
您有语法错误。 RewriteRule需要单行。
尝试此规则:
RewriteEngine On
RewriteBase /MyProject/
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
# Allows for one wildcard: page
RewriteRule ^([^/]+)/?$ index.php?page=$1 [L,QSA]
# Allows for two wildcards: page, action
RewriteRule ^([^/]+)/([^/]+)/?$ index.php?page=$1&action=$2 [L,QSA]
# Allows for three wildcards: page, action and id
RewriteRule ^([^/]+)/([^/]+)/([^/]+)/?$ index.php?page=$1&action=$2&id=$3 [L,QSA]