我当前的.htaccess文件如下所示:
RewriteEngine on
RewriteRule ^pages/([\w-]+)/artwork/?$ painting.php?painting=$1 [QSA,NC,L]
RewriteCond %{THE_REQUEST} /([^.]+)\.php [NC]
RewriteCond %{THE_REQUEST} /([^.]+)\.html [NC]
RewriteRule ^ /%1 [NC,L,R]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^ %{REQUEST_URI}.php [NC,L]
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule ^ %{REQUEST_URI}.html [NC,L]
我试图使网址,而不是看起来像example.com/artwork/paintingURL
,我得到这个页面从<a href = "painting?painting=<?=$paintingURL?>">
.我已经在这里搜索,我已经得到的解决方案,没有一个答案似乎为我工作.
更新:使用下面的RavinderSingh13的解决方案后,我现在得到404页面未找到错误的重定向网址.在painting.php
:
<?php
if(isset($_GET['painting'])) {
include('include/conn.php');
$paintingURL = $_GET['painting'];
$sql = "SELECT * FROM `paintings` WHERE `painting_URL` = '$paintingURL'";
$result = $conn->query($sql);
global $paintingName;
global $paintingDesc;
global $paintingImg;
global $pageTitle;
if(mysqli_num_rows($result) > 0){
while ($row = mysqli_fetch_assoc($result)){
$paintingName = $row['painting_Name'];
$pageTitle = "Site Name - ".$paintingName;
$paintingDesc = $row['size_description'];
$paintingImg = $row['image_ID'];
}
} ?>
jsfiddle,用于链接的服务方式:https://jsfiddle.net/h65u9fc3/
1条答案
按热度按时间pftdvrlh1#
使用显示的示例,请尝试以下.htaccess规则文件。
请确保: