Results 1 to 6 of 6

Thread: Rewrite URL's

  1. #1
    Join Date
    Aug 2007
    Posts
    22
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Rewrite URL's

    I'm looking for a quick way to remove .php extension from the URL and add a backslash at the end (also known as a trailing slash).

    Example:
    original url: www.domain.com/contact.php
    rewritten ur: www.domain.com/contact/

    I've been looking online for quite sometime now and cannot find a resource that adds a "/" at the end.

    Additionally I was wondering if there is any way to keep the rewrite URL in only one directory. I dont want to have have a .htaccess file in every single directory with rewrite engine turned off.

  2. #2
    Join Date
    Mar 2008
    Posts
    122
    Thanks
    17
    Thanked 5 Times in 5 Posts

    Default

    Do you mean when you go on: www.domain.com/contact.php it turns too: www.domain.com/contact/, because if you do in the contact.php file enter this:
    Code:
    <?php
    
    header("Location: http://www.domain.com/contact/");
    
    ?>
    Hope this helps .

  3. #3
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    No hmsnacker, he wants to know how to rewrite it.
    Use mod_rewrite.
    Jeremy | jfein.net

  4. #4
    Join Date
    Mar 2008
    Posts
    122
    Thanks
    17
    Thanked 5 Times in 5 Posts

    Default

    I said:

    Do you mean
    And:

    because if you do

  5. #5
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I was just saying.
    Jeremy | jfein.net

  6. #6
    Join Date
    Jun 2008
    Posts
    589
    Thanks
    13
    Thanked 54 Times in 54 Posts
    Blog Entries
    1

    Default

    That's PHP. JavaScript would be like this:

    Code:
    <script type="text/javascript">
    function change_url()
    {
    var u = "http://www.domain.com/contact.php"; // Only 33 Characters - Start with ZERO - charAt() cannot exceed 32;
    
    u.charAt(29) = " ";
    u.charAt(30) = "";
    u.charAt(31) = "";
    u.charAt(32) = "";
    u.charAt(29) = "/";
    
    location.href = u;
    }
    </script>
    That should do it. I didn't test it yet, but you are welcome to try it!

    -magicyte

Bookmarks

Posting Permissions

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