Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Simple rewriterule

  • 22-11-2009 03: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