SitePoint Sponsor

User Tag List

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

    Cool how to make rewrite transparent!?

    Hi!

    I have the following rule, which i would like to make transparent way..
    Now it shows the users the long url..(after they try to visit the short, and the rule "forward" them)

    so rule:

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^gallery/([^\.\?/]+)/([A-Za-z_0-9\-]+) $http://pet.site.hu/modules.php?set_albumName=$1&id=$2&op=modload&name=gallery&file=index&include=view_photo.php [QSA,L]


    I thought L is the key..but seems not.. :/

  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,

    The way to SHOW the new URL is to use the flag [R=301] to make it a permanent redirect. In other words, yours should NOT be showing the new URL EXCEPT that your $ was misplaced (there should have been NO space before and a space after).

    That said, you don't normally redirect to an absolute URL so, assuming that you're ON the pet.site.hu server, just use:
    Code:
    RewriteEngine On
    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]
    Does the gallery/something REQUEST_URI really have a query string attached? If not, drop the "QSA," from the flag list leaving just the Last flag.

    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,
    The way to SHOW the new URL is to use the flag [R=301] to make it a permanent redirect. In other words, yours should NOT be showing the new URL EXCEPT that your $ was misplaced (there should have been NO space before and a space after).
    Regards,

    DK

    Hi, i dont really understand then..
    spaces are ok.
    but redirect is NOT transparent
    You can check it out at http://pet.site.hu/gallery/whwt
    it redirects to
    http://pet.site.hu/modules.php?set_a...view_album.php
    it's nice, but it's NOT transparent.

    The WHOLE rewriteruleset follows:

    RewriteEngine On

    RewriteBase /
    RewriteRule ^gallery(/|/albums.php)?$ http://pet.site.hu/modules.php?op=mo...ery&file=index [L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^gallery/([^\.\?/]+)/([A-Za-z_0-9\-]+)$ http://pet.site.hu/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/([^\.\?/]+)/?$ http://pet.site.hu/modules.php?set_albumName=$1&op=modload&name=gallery&file=index&include=view_album.php [QSA,L]

    Happy to see any advice :/

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

    changes.

    It ALMOST works!

    the problem was absolut urls, yeah, thanks!

    Now "only" the problem is that pages try to load relativepathed images, etc from this path... so they are missing :/

    Any way to help this out?

  5. #5
    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,

    Yes. The article at datakoncepts.com/seo provides a warning about this AND two ways around this problem: Absolute links OR use of the HTML base tag. The latter is what I advocate as it's simplest and is basically just a one-liner in your modules.php script.

    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

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

    Yes. The article at datakoncepts.com/seo provides a warning about this AND two ways around this problem: Absolute links OR use of the HTML base tag. The latter is what I advocate as it's simplest and is basically just a one-liner in your modules.php script.


    Regards,

    DK
    EEEHM

    yes, base tag did the job (not in that php but so..)
    BUT on the other hand, that path is not always the same... :/

  7. #7
    SitePoint Member
    Join Date
    Mar 2005
    Posts
    17
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by joeje
    EEEHM

    yes, base tag did the job (not in that php but so..)
    BUT on the other hand, that abs.path is not always the same... :/
    AND i can not use php in that (.tpl file of phbb), so it makes me sick :/

  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,

    Ah, but you KNOW the location of the directory from which you're running your files (and the files generated by your template) so base will work -- been there and done that! Moreover, since the base tag is PURE HTML, it's available to EVERY file in which you write or create HTML code.

    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

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

    Wink

    Quote Originally Posted by dklynn
    joe,

    Ah, but you KNOW the location of the directory from which you're running your files (and the files generated by your template) so base will work -- been there and done that! Moreover, since the base tag is PURE HTML, it's available to EVERY file in which you write or create HTML code.

    Regards,

    DK

    Nice, finally solved it! managed to get the php code in there
    im happy :P
    thanks, bro

  10. #10
    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,

    ewe bee velcome!

    It's Party Time!

    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
  •