rewrite problem... please can someone help!?

Discussion in 'Apache' started by matthew1471, Sep 5, 2007.

  1. #1
    http://subdomain.domain.co.uk/index.php?string=surname

    i'm trying to redirect the above page to

    subdomain.domain.co.uk/surname

    in index.php I have the following links to reload the page with new data

    <a href="index.php?string=surname" title="title">surname</a>
    <a href="index.php?string=surname2" title="title">surname2</a>


    I've tried the following in my htaccess

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^/(.*)/$ /index.php?$1

    but it doesn't make any difference to the displayed url, or the url in index.php

    Please can someone help?!
     
    matthew1471, Sep 5, 2007 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #2
    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^index.php?string=(.*)$ http://www.domain.com/$1/ [R=301,L]

    Though it might do an infinite loop. Links should be changed to static before search engines find them.
     
    Nintendo, Sep 5, 2007 IP
  3. matthew1471

    matthew1471 Active Member

    Messages:
    41
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    51
    #3
    Thanks Nintendo :) I think i'm slowly understanding it now...

    the links in my php page should coded like like this...

    <a href="http://subdomain.domain.co.uk/surname.html">surname</a>

    and in the htaccess, my rewrite code should be like this...

    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^index.php?string=(.*)$ http://subdomain.domain.co.uk/$1.html

    Nearly understanding it! I hope that's right?
     
    matthew1471, Sep 5, 2007 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #4
    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)\.html$ index.php?string=$1 [L]
     
    Nintendo, Sep 6, 2007 IP