.htaccess一到三/级别

时间:2015-11-17 21:45:46

标签: php apache .htaccess mod-rewrite

我需要RewriteRules接受类似的内容:

mysite/courses going to mysite/index.php?page=courses

mysite/courses/add going to mysite/index.php?page=courses&action=add

mysite/courses/edit/3 goint to mysite/index.php?page=courses&action=edit&id=3

目前,我正在使用:

RewriteEngine On
RewriteRule %{REQUEST_FILENAME} !-f
RewriteRule %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI}  !\.(php|html?|jpg|gif|js|css)$
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ index.php?page=$1&action=$2&id=$3

但是,当我尝试不起作用的mysite / courses /时。

此致

1 个答案:

答案 0 :(得分:1)

我得到了这个.htaccess

RewriteEngine On
RewriteRule %{REQUEST_FILENAME} !-f
RewriteRule %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI}  !\.(php|html?|jpg|gif|js|css)$
RewriteRule ^([^/]*)/?([^/]*)/?([^/]*)$ index.php?page=$1&action=$2&id=$3