70 users online (0 members and 70 guests)  




  Results 1 to 11 of 11

Related

  1. adding sound to a Html web page    Forum: HTML Forum
    Replies: 1
  2. Replies: 2
  3. Adding search function to a HTML website    Forum: HTML Forum
    Replies: 5
  4. Adding a soundbyte with HTML...    Forum: HTML Forum
    Replies: 2
  1. #1
    joetech1's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2005
    Posts
    4

    Adding HTML extension to link

    Anyone have a script that will automatically add the ".html" extension to a link when it is clicked:

    <a href="tom">tom</a>

    I want this to link to call "tom.html" and not just "tom".

    It sounds doppy but it is part of a bigger problem and I can't easily change the link simply by adding the ".html" to the link.

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Hi, welcome to the forums.

    There are a few things we could do, but they would all rely on changing the href tag to include javascript. I presume if you can't change the .html then you can't change anything.

    As I see it, theres no way out of this. However, if you could give us some more details of your situation then we might be able to suggest a work-around.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    joetech1's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2005
    Posts
    4

    Adding HTML extension to link

    QuietDean,

    Thanks for responding. My problem is that I have about 8 pages each with up to 100 link entries that have to be updated a couple times a month.

    The pages being updated are taken from a manufacturer website and reformated to fit into my website. The only way that I can efficiently and reasonably do this is by using a Search/Replace command. The example below shows how that is not possible because there is no common text.
    ------------------------------------------
    <a href="desc.asp?p=PT-102A">PT-102A</a>

    <ahref="http://thekramerstore.com/VM-1110xl">VM-1110xl</a>

    <a
    href="http://thekramerstore.com/SD-7816">SD-7816</a>
    ------------------------------------------

    The manufactuerer is using an ASP link and I am not. But I can easily replace the "desc.asp?p=" part with the Search/Replace function.

    So my problem is to find some script that will tell the page that any clicked links should add the ".html" extension to the file name.

    Thanks for listenting.

    Joe

  4. #4
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    As long as you have access to your webserver, and the webserver support .htaccess and mod_rewrite, we can do this.

    first we do the replace

    "desc.asp?p=" to "description/"

    it doesn't matter what we call that, its just a tool so our mod_rewrite rule is easier to write.

    Then create a .htaccess file in your root web directory. In it, we put

    Code:
    RewriteEngine On
    RewriteRule ^description/([^/\.]+)/?$ $1.html [L]
    In theory, you can then keep your links going to

    http://thekramerstore.com/description/SD-7816

    And the rewrite rule will automatically serve up
    http://thekramerstore.com/SD-7816.html

    Whilst keeping the address visible as the original one.

    Now, first thing is to check your host is using apache (these are Apache re-write's) and they have mod_rewrite installed and .htaccess allowed on your account.

    If all thats true, and it doesn't work, post back because rewrite rules are tricky and I could easily have got that wrong
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  5. #5
    HTML's Avatar
    Administrator

    Status
    Offline
    Join Date
    Aug 2000
    Posts
    3,441

    Follow HTML On Twitter Add HTML on Facebook Add HTML on Google+ Add HTML on Linkedin Visit HTML's Youtube Channel
    damn you are good

  6. #6
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Presuming it works
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  7. #7
    joetech1's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2005
    Posts
    4

    Thumbs up Adding HTML extension to link

    I am currently using server software called Sambar Server V5.3 - http://sambar.org

    I have an email into their tech support to find out what they support. The ".htaccess " is mentioned in the Features section but not the "mod_rewrite".

    Another thing you should be aware of is that I have about 12 other websites running on the same server. Will that interfere with the operations of them? Do I need to have a dedicated server just for this site?

    Also, I noticed that the Sambar does ASP. Is this something I could do easily so that I can use all of the ASP code without making changes?

    And YES, you ARE good! I have posed this question on several forums and you are the only one to tell me that there may be an alternative.

    Thanx!

  8. #8
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    That sambar worries me. I have only used mod_rewrite on apache.

    As long as your website and the other 12 have different document roots, you should be fine. Eg

    a .htaccess when placed in /usr/home/web/website1 will affect /usr/home/web/website1,/usr/home/web/website1/example but will not affect /usr/home/web/website2
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  9. #9
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Oh, and if your website supports ASP then yes, you can use ASP code directly. However, unless that website is on the same server/website you will not get access to the code itself unless, of course, its yours
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  10. #10
    joetech1's Avatar
    New User

    Status
    Offline
    Join Date
    Feb 2005
    Posts
    4
    I just heard back from Sambar. Mod_rewrite is NOT supported. So I suppose that won't work.

    I know absolutely nothing about ASP so I don't know how to answer your question. All I can tell you is that it is my server running my software.

    Thanks for the loaned brain cells!

  11. #11
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Crumbs, I'm sorry. I have never used Sambar so I haven't got enough knowledge to suggest a solution.

    I do know ASP well, but I cannot think of any tricks for that.

    Another option...if you used a text editor that supported regex, you Might be able to do the find/replace even though there is no common text. With regex you could define whatever text is between certain markers is to be replaced.

    Off hand, I know www.textpad.com supports regex in its find & replace.

    Find an introduction to regex here: http://www.regexbuddy.com/ , though I imagine it will be similar to the regex I used in the mod_rewrite rule.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?



Tags for this Thread