1

我在 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 数组中的 ajax 部分。见下文 page.php

print_r($_GET);
$url = $_GET['section'];

输出是

Array
(
    [ajax] => true
)

知道为什么它没有检测到其他变量吗?

4

1 回答 1

3

启用mod_rewrite.htaccess通过httpd.conf然后将此代码放入您的 DOCUMENT_ROOT/.htaccess文件中:

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

RewriteRule ^page/([^/]+)/ /page.php?section=$1 [NC,QSA,L]
于 2013-09-25T12:17:06.993 回答