[英]mod_rewrite rules
I'm trying to get the data after the URL and sent back to the home page. 我正在尝试获取URL之后的数据并发送回首页。 I have had errors in the .htaccess file on one server so I am trying it out on another server.
我在一台服务器上的.htaccess文件中有错误,所以我正在另一台服务器上尝试它。
The links down the side of http://www.newbiemoneymakers.com/bank/
should do directly to http://www.newbiemoneymakers.com/bank/index.php
where I then get the title. http://www.newbiemoneymakers.com/bank/
下方的链接应直接指向http://www.newbiemoneymakers.com/bank/index.php
,然后在其中获得标题。
My .htaccess file says: 我的.htaccess文件说:
RewriteEngine on
RewriteRule ^http://www.newbiemoneymakers.com/bank/([^/\.]+)/?$ index.php?title=$1 [L]
My index page says: 我的索引页面说:
<?php
include('includes/functions.php');
$activeTab = "navhome";
$sent = false;
$title = (isset($_GET['title']))? mysql_real_escape_string($_GET['title']) : 'Home';
$title = str_replace('-',' ', $title);
if($title != '') {
$sql = "SELECT *
FROM contents
WHERE name LIKE '%$title%'
LIMIT 1";
$result = @mysql_query($sql);
$row = mysql_fetch_assoc($result);
}
//Set page title
$pagetitle = (isset($row['name']) && $title != 'Home')? ucwords($row['name']) : "Bank Charges";
?>
But when I click on any of the links (eg http://www.newbiemoneymakers.com/bank/bank-charges-refund/
) it gives me a 404 page! 但是,当我单击任何链接(例如
http://www.newbiemoneymakers.com/bank/bank-charges-refund/
)时,它会显示404页!
Do you know where I am going wrong? 你知道我要去哪里错吗?
Ian 伊恩
The pattern of a RewriteRule
is just tested agains the URI path (in .htaccess files without the contextual per-directory prefix, so in the root directory without the leading /
). 只需再次测试URI路径(在不带上下文每个目录前缀的.htaccess文件中,因此在根目录中不带
/
)再次测试RewriteRule
的模式。
So this should work: 所以这应该工作:
RewriteRule ^bank/([^/.]+)/?$ bank/index.php?title=$1 [L]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.