SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry short urls into long Transparent AND BACK visible!?!

    Hi!

    I have the following rule, which sets short urls into long ones (which php can process):
    ------
    Code:
    RewriteEngine On
    
    RewriteBase /
    RewriteRule ^gallery(/|/albums.php)?$ modules.php?op=modload&name=gallery&file=index[/url] [L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^gallery/([^\.\?/]+)/([A-Za-z_0-9\-]+)$ /modules.php?set_albumName=$1&id=$2&op=modload&name=gallery&file=index&include=view_photo.php [QSA,L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^gallery/([^\.\?/]+)/?$ modules.php?set_albumName=$1&op=modload&name=gallery&file=index&include=view_album.php [QSA,L]
    ----------------------


    Nah, its all fine, but i want the URLs appear to users ON the pages(php)-so under images, in text links etc, to show SHORT urls. But in the "background" long urls have to work, forms get variables from urls..etc.

    IS IT possible with some kinda rewriterule or something? :O

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    joe,

    Use the R=301 flag with the Last flags.

    Since you're adding query strings, I have to ask if the links already have query strings attached. If not, you don't need the Query String Appended flag (which will allow PRE-existing query strings to pass through your rewrites).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by dklynn
    joe,

    Use the R=301 flag with the Last flags.

    Since you're adding query strings, I have to ask if the links already have query strings attached. If not, you don't need the Query String Appended flag (which will allow PRE-existing query strings to pass through your rewrites).

    Regards,

    DK
    Huh. Sorry I do not understand You.
    Which links "have already query strings attached" ?
    and where to use R=301? :/

    Sorry..maybe my english..if not my stupidity.

    (could be much faster in chat? Are You reachable/disturble? )

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    joe,

    I don't use "chat" so that's not really an option.

    The query string question is basically this: If your links don't have a query string attached when they get to mod_rewrite, then you don't need the QSA flag(s). Those are only to keep pre-existing query strings (while you add your new query strings).

    The R=301 flags go like this:

    Code:
    RewriteEngine On
    
    RewriteBase /
    RewriteRule ^gallery(/|/albums.php)?$ modules.php?op=modload&name=gallery&file=index [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^gallery/([^\.\?/]+)/([A-Za-z_0-9\-]+)$ /modules.php?set_albumName=$1&id=$2&op=modload&name=gallery&file=index&include=view_photo.php [R=301,L]
    
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^gallery/([^\.\?/]+)/?$ modules.php?set_albumName=$1&op=modload&name=gallery&file=index&include=view_album.php [R=301,L]
    Note: I replaced your QSA flags 'cause I don't believe you need them.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    Quote Originally Posted by dklynn
    joe,

    The query string question is basically this: If your links don't have a query string attached when they get to mod_rewrite, then you don't need the QSA flag(s). Those are only to keep pre-existing query strings (while you add your new query strings).

    The R=301 flags go like this:

    Note: I replaced your QSA flags 'cause I don't believe you need them.

    Regards,

    DK
    Hi, the query string: not really query string, because the short urls goes to the mod_rewrite, which makes into into da real query string from parts of the short url.

    When I put R=301-s in, i see the LONG urls everywhere! so rewrite is no more transparent.
    Neither can i have short urls in the page.

    So where i am at the moment is this:

    The green is GOOD, the RED is BAD! Red should display SHORT urls, which in the "background" should goes to the long(to function properly).

    Maybe i need some rules TOO, where rules write long back to short NOT transparently?

    dunno what to do :O
    Last edited by joeje; Apr 10, 2005 at 17:40.

  6. #6
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    joe,

    Okay, that's what I thought about the QSA. The R=301 was ONLY to confirm that the QSA was not required because there was no query string there in the first place. After that, the R=301 should be removed 'cause you're trying to avoid showing the long URLs.

    RewriteRule(s) will NOT change the URLs in the page to that shown by your jpg. My suggestion is to rewrite the code which generates your URLs so that the short URLs are created (and used by the links).

    Remember, it's a two-way street: You've got to create the short URLs properly so Apache can serve the long versions while you're showing the short ones in the browser's Location box.

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  7. #7
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy

    DK,

    everything is fine, expect 1 thing:
    IE sucks, it DOES care about base href when setting icon urls, but ON THE VERY SAME PAGE, when i click on a menu item, it goes to BAD url (do not cares about base href).
    Firefox rocks, that do it right with the same code.

    both generate/get the same page, but with the same source, they goes to different urls ;>
    nice

    <base href="http://pet.site.hu/modules.php">
    FIREFOX goes to: http://pet.site.hu/modules.php?paren...do_command.php
    BUT IE GOES TO:
    http://pet.site.hu/gallery/modules.p...do_command.php

    so IE uses what is in the navigation toolbar of explorer..NOT what is specified in the base href..

    Any ideas? :O

  8. #8
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,692
    Mentioned
    20 Post(s)
    Tagged
    3 Thread(s)
    joe,

    Suggestions? Another pie in the face for Mr Gates? Well, that and more is deserved but ...

    I agree that Firefox rocks! Love the tabs (started with Netscape 6) and so much more! HOWEVER, as long as most people are lazy (and don't know/care that IE makes them subject to all sorts of viruses, etc), you will HAVE to deal with IE's problems. Perhaps you'll have to search for a "hack" to make IE comply with HTML coding (i.e., if you're using PHP, you can code for good browsers and differentiate that from IE and only serve the right HTML to your visitors).

    Regards,

    DK
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator


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
  •