Php htaccess URL重写$\u get函数用法

Php htaccess URL重写$\u get函数用法,php,.htaccess,get,rewrite,Php,.htaccess,Get,Rewrite,我一直在尝试对一个网站进行htaccessurl重写(R=302),该网站使用$\u get函数通过使用字符串来拉取内容页。例如,我正在尝试更改以下内容: 为此: 但是,我已经成功地将其设置为,如果我使用query第二个URL,它将重定向index.php文件中的页眉和页脚数据,但它不会获取内容的CSS或$\u get信息。以下是htaccess条目和$\u get信息: RewriteEngine On RewriteBase / RewriteRule ^(.*?)/$ /index.p

我一直在尝试对一个网站进行htaccessurl重写(R=302),该网站使用$\u get函数通过使用字符串来拉取内容页。例如,我正在尝试更改以下内容:

为此:

但是,我已经成功地将其设置为,如果我使用query第二个URL,它将重定向index.php文件中的页眉和页脚数据,但它不会获取内容的CSS或$\u get信息。以下是htaccess条目和$\u get信息:

RewriteEngine On
RewriteBase /
RewriteRule ^(.*?)/$ /index.php?page=$1 [NC,QSA,L]
RewriteRule ^(.*?)/$ $1.html [NC,L,QSA,R=302]


<?php
$folder = '';
$ext = 'html';
if (!$_GET['page'] || strpos($_GET['page'], '/') === true)
$path = 'home.' . $ext;
else $path = $_GET['page'] . '.' . $ext;
if (!file_exists($path)) {
 $messages = array(
      '404: Page does not exist; Please check the URL you entered.',
      '404: Error 404, please check the URL of the page.'
 );
 print $messages[ rand(0, (count($messages) - 1)) ];
}
elseif (!@include($path)) print '300: couldn\'t get the page';
?>
重新编写引擎打开
重写基/
重写规则^(.*?/$/index.php?页面=$1[NC,QSA,L]
重写规则^(.*?/$$1.html[NC,L,QSA,R=302]

任何帮助都将不胜感激。我一直试图修改php代码,但没有成功,因为我认为这就是问题所在。

首先,您的两个重写规则具有相同的条件,因此只有第一个规则会得到满足。我认为您可能只想在服务器上不存在请求的uri时重写

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*?)/?$ /index.php?x=$1 [L]

您试图用
.html
做什么?