views:

52

answers:

1

I'm trying to get the data after the URL and sent back to the home page. I have had errors in the .htaccess file on one server so I am trying it out on another server.

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.

My .htaccess file says:

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 (e.g. http://www.newbiemoneymakers.com/bank/bank-charges-refund/) it gives me a 404 page!

Do you know where I am going wrong?

Ian

+2  A: 

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 /).

So this should work:

RewriteRule ^bank/([^/.]+)/?$ bank/index.php?title=$1 [L]
Gumbo
I still cannot get it to work! my .htaccess file now says:RewriteEngine onRewriteRule ^bank/([^/.]+)/?$ bank/index.php?title=$1 [L]I have uploaded it to the directory and to the root directory but still getting a 404!
My rule was intended for the .htaccess in your root directory. And it works for me. Are you sure mod_rewrite is enabled?
Gumbo
Ye, i asked the hosting if it was installed and enabled!
Hm. Did you try a simpler rule to proof that? Somthing like `RewriteRule ^ http://example.com [L,R]`
Gumbo
I will give it a go now!
I have tested that mod_rewrite is working! I did a little exaple where one page directs to another and it works! I still cant get the main problem working tho!
Thanks for the help! I have just fixed it! RewriteEngine onRewriteRule ^([^/\.]+)/?$ index.php?title=$1 [L]
So you wanted a rule for your bank directory? You should have said that.
Gumbo