.htaccess重写mod_rewrite模块的问题

时间:2013-09-25 12:14:20

标签: regex .htaccess mod-rewrite

我在html中生成了以下网址

http://www.xxx.com/page/26/website-design-services?ajax=true

配置.htaccess语法来读取页面id的值是

# BEGIN Rewrite
<IfModule mod_rewrite.c>
RewriteEngine on
#RewriteBase /
RewriteRule ^page/([^/]+)/?(.*)$ page.php?section=$1  [QSA,L]
</IfModule>
# END Rewrite

当我调用php文件来执行下面的get时,它只返回GET数组中的ajax部分。见page.php

中的以下内容
print_r($_GET);
$url = $_GET['section'];

输出

Array
(
    [ajax] => true
)

知道它为什么不检测其他变量?

1 个答案:

答案 0 :(得分:3)

启用mod_rewrite.htaccesshttpd.conf,然后将此代码放入DOCUMENT_ROOT/.htaccess文件中:

Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

RewriteRule ^page/([^/]+)/ /page.php?section=$1 [NC,QSA,L]
相关问题