Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Simple rewriterule

Options
  • 22-11-2009 3:13am
    #1
    Closed Accounts Posts: 1,619 ✭✭✭


    I want to create a rewrite rule to basically remove suffix from the end of my URLs.

    Lets say I have a URL: mysite.com/info.php

    And want it to appear as: mysite.com/information

    I use this:
    RewriteEngine On
    RewriteRule information info.php
    

    This works fine, but if the user appends a slash at the end i.e. mysite.com/information/ the page loads but no CSS or Javascript loads.

    The file structure is like this:
    info.php
    css/style.css
    script/js.js

    Relative links to files are used everywhere.

    Why does using information work whereas information/ breaks the links?

    I'm not that similar with .htaccess but from what I've seen the documentation is piss poor.


Comments

  • Closed Accounts Posts: 5,082 ✭✭✭Pygmalion


    Bob_Harris wrote: »
    I want to create a rewrite rule to basically remove suffix from the end of my URLs.

    Lets say I have a URL: mysite.com/info.php

    And want it to appear as: mysite.com/information

    I use this:
    RewriteEngine On
    RewriteRule information info.php
    
    This works fine, but if the user appends a slash at the end i.e. mysite.com/information/ the page loads but no CSS or Javascript loads.

    The file structure is like this:
    info.php
    css/style.css
    script/js.js

    Relative links to files are used everywhere.
    This is causing it, the browser thinks that "information/" is a folder instead of a file called "information", it looks for "information/css/style.css" instead of just "css/style.css".

    Answer is to either use absolute links or (preferably) never link to "information/" as this ca really confuse the browser.


  • Closed Accounts Posts: 1,619 ✭✭✭Bob_Harris


    Yeah I'd prefer not to use absolute links.

    I notice on some websites if you append a slash at the end of the URL, it gets stripped away by some process.

    Should I even be bothered by this?


Advertisement