www.webdeveloper.com
Results 1 to 6 of 6

Thread: .htaccess mod rewrite help please!

Hybrid View

  1. #1
    Join Date
    Jul 2008
    Posts
    48

    Angry .htaccess mod rewrite help please!

    Hi All,

    i am desperatly looking for some help with mod rewrites,

    i have set up my site to show "tidy urls" which are virtual urls they dont exist, i want to now redirect these urls to the actual url which is valid if that makes sence?

    i have a db of 100,000 plus products all using one page to send data in the url to pullout the specific data to show

    so i have a real page like so
    Code:
    http://www.my-website.com/results.php?category=dvd&product=The Hurt Locker
    now i have set it up so when the user clicks on this products link it goes to
    Code:
    http://www.my-website.com/dvd/the_hurt_locker
    which does not exist

    now as i understand it i have to ue mod rewrite to point the second url to the first? is that right?

    so i have found this piece of code which i have tried to modify
    Code:
     RewriteEngine On  
       
     RewriteCond %{SCRIPT_FILENAME} !-d  
     RewriteCond %{SCRIPT_FILENAME} !-f  
       
     RewriteRule ^users/(\d+)*$ ./profile.php?id=$1  
     RewriteRule ^threads/(\d+)*$ ./results.php?id=$1  
       
     RewriteRule ^search/(.*)$ ./search.php?query=$1
    but i dont really unertand how it all works and am really struggling to get anywhere with this

    any help is apprecated

    p.s the categorys in the urls are not always dvd

  2. #2
    Join Date
    Jul 2008
    Posts
    48
    ok im getting somewhere

    found a generator online and came up with this
    Code:
    RewriteEngine On
    RewriteRule ^([^/]*)/([^/]*)$ /price_finder2.php?category=$1&product=$2 [L]
    and now when i type in this for example
    http://www.kernow-connect.com/dvd/the%20hurt%20locker

    it loads up a page with the correct data but there is no css formatting, what do i have to do get this to work?

    EDIT
    ====

    All css has been removed from the entire site??? (ive temp removed the rewrite code). any ideas please?

    thanks
    Luke
    Last edited by msd_luke; 05-05-2010 at 06:24 PM.

  3. #3
    Join Date
    Feb 2010
    Posts
    7
    Update the links of your css. You can do it this way:

    <link href="/css/style.css" rel="stylesheet" type="text/css" />

    Hope this helps

  4. #4
    Join Date
    Jul 2008
    Posts
    48
    hi lonelygirl86,

    i have updated the css links like so
    Code:
    <link href="/autosuggest/css/style.css" rel="stylesheet" type="text/css" />
    <link href="/css/rating.css" rel="stylesheet" type="text/css" />
    <link href="/css/newcss.css" rel="stylesheet" type="text/css" />
    on the page which my rewrite rule applies to but it still doesnt show the css styling
    any ideas?

    thanks for your reply
    Luke

  5. #5
    Join Date
    Jul 2008
    Posts
    48
    ok i have managed to solve most of my problems by adding the following to my htaccess
    Code:
    RewriteCond &#37;{SCRIPT_FILENAME} !-d  
    RewriteCond %{SCRIPT_FILENAME} !-f
    now the only problems i have are all the links on the new virtual pages have an extra directory in them

    e.g i have a link home which should be
    Code:
    www.home.com/index.php
    but it is for some reason adding dvd directory in it like so
    Code:
    www.home.com/dvd/index.php
    so none of the links are currently working on that page?

    any ideas?
    thanks
    Luke

  6. #6
    Join Date
    Jul 2008
    Posts
    48
    solved!!! added / to all my links and it removed the extra directory

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles