Results 1 to 2 of 2

Thread: need help with mod_rewrite

  1. #1
    Join Date
    Jan 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default need help with mod_rewrite

    Hi,

    I am trying to make profile pages for members on my site, and I want to use mod_rewrite to load specific content on their profile pages, from different links throughout the website. The catch, however, is that I don't want search engines to view each different link as a different web page.

    Here's my page (without mod_rewrite):

    mysite.com/profile.php?member=peter&tab=photos
    mysite.com/profile.php?member=peter&tab=biography

    The page has both sections loaded, but separated by a tabs using jQuery, so you click through the tabs to view the loaded information on the page (no ajax). I just want to use the "tab" parameter to tell the page which tab to make active first. Here is the ideal rewrite I'd like:

    mysite.com/peter#photos
    mysite.com/peter#biography

    But I cannot find a way to do this with mod_rewrite. I want to avoid doing this:

    mysite.com/peter/photos
    mysite.com/peter/biography

    because a search engine would see the two links as two separate pages, and I would halve my SEO for links directing to www.mysite.com/peter

    Is there some way I can use mod_rewrite to tell my source page which tab of content to make visible first, without search engines viewing the url's as different pages?

    Hope this makes sense
    Scott

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    1. #name is an anchor on a page. It may not be possible to use this (and probably would be a bad idea) for a "real" link. I'm not sure it's even transmitted as part of the request. Basically it means "go to the URL before the #, then jump to the part of the page with the label from after the #", so it's completely based on the browser. Note how the page jumps after it finishes loading.

    2. I don't know much about mod_rewrite, trying to learn more, but what I do know can be found here:
    http://dynamicdrive.com/forums/showthread.php?t=51923

    If you know php well but not mod_rewrite that's a way around it, or at least some more info on how to approach this in a basic way.


    If you want the search engine to see it as the same page, then the only way to do that is to use something that is not part of the URL: either get variables (?v=1) or anchors (which can't be used for this exactly).

    So I suggest just simplifying the system:
    rewrite your code so that you have shorter get variables, and just go with that:
    /yourpage.php?peter

    PHP:
    if (isset($_GET['peter']))......
    Or, use $_SERVER['QUERY_STRING'] which would in that example be 'peter'.

    Or something like that. It's a starting point.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •