我是新的htaccess重定向和重写。我已经通过了follwing htaccess的代码htaccess重定向并重写不重定向到一个网址
Options +FollowSymlinks -Multiviews
RewriteEngine on
RewriteCond %{QUERY_STRING} ^celeb_id=(.*)$
RewriteRule ^celeb_gallery\.php$ /celebrity/%1? [R=301]
转换以下网址
example.in/celeb_gallery.php?celeb_id=1
为
example.in/celebrity/1
再次获得的celeb_id
值我在htaccess的添加followig码文件
RewriteRule ^celebrity/([^-]+)$ /celeb_gallery.php?celeb_id=$1 [L]
我上传了htaccess文件。当网址example.in/celeb_gallery.php?celeb_id=1
被激怒时,它会在地址栏中更改为example.in/celebrity/1
。
但是该网页在Chrome中显示错误This Webpage has a direct loop
,在Firefox中它显示The page isn't redirecting properly
。为什么它不工作...?
示例工作sample.php文件仅包含以下代码:其工作没有任何CSS。
<?php
echo "This is an sample page<br>";
echo "Celeb id:".$_REQUEST["celeb_id"];
echo "<br>";
?>
celeb_id传入celeb_gallery.php文件,但它不打开我认为的任何样式表。和代码是在这里:
<?php include('cpanel/common/dbconnect.php');?>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<?php
$ncel = "SELECT * FROM celebrity WHERE cel_id = ".$_REQUEST['celeb_id']."";
$ncel_e = mysql_query($ncel);
$ncel_f = mysql_fetch_array($ncel_e)
?>
<title><?=$ncel_f['name']?> | Site Title</title>
<?php include('common/css_js.php'); ?>
</head>
样式表被称为<?php include('common/css_js.php'); ?>
和它不工作,我认为。
hi mukii您可以更改'RewriteRule ^(。*)$ /名人/([^ - ] +)$ /celeb_gallery.php?celeb_id=$1 [L]' –
其显示内部服务器错误@ nu1_ww –
can你试试这个吗? '选项+的FollowSymLinks -Multiviews RewriteEngine叙述上 的RewriteCond%{} REQUEST_FILENAME!-f 的RewriteCond%{} REQUEST_FILENAME!-d 的RewriteCond%{QUERY_STRING}^celeb_id =(。*)$ 重写规则^ celeb_gallery \ $ .PHP /名人/%1吗? [L]' –