Forum Moderators: phranque

Message Too Old, No Replies

mod_rewrite for the REALLY dense

emphasis on the really part

         

pcgamez

3:18 am on Feb 17, 2004 (gmt 0)

10+ Year Member


right now, all my URLs look as follows:

http://www.site.com/book.php?id=19041
http://www.site.com/author.php?id=2058
http://www.site.com/series.php?id=18
http://www.site.com/list.php?type=book
http://www.site.com/search.php?item=david+weber
http://www.site.com/list.php?type=series&by=genre

Now, I understand that I need to use mod_rewrite to get the pages to be looked at by most spiders. What I don't get is how exactly do do it. I have looked at most, if not all the tutorials out there and they end up covering so much that I get really lost. Can anyone walk me through what I need to do to get the URLs to be crawled using only .htaccess?

jdMorgan

3:30 am on Feb 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



pcgamez,

Welcome to WebmasterWorld [webmasterworld.com]!

> what I need to do to get the URLs to be crawled using only .htaccess?

I'm afraid it can't *all* be done using .htaccess. Your .htaccess file is processed after an HTTP request is received but before any content is served or any scripts are run. What this means practically is that .htaccess on acts on the "front end" of a request. It can therefore change an incoming URL and rewrite it to a different URL or internal filename. But it cannot change anything about the output of the server, including script output.

In outline form, here's what you probably want to do:

  • Modify your script to output search-engine-friendly static-looking short URLs on pages.
  • When one of these short static URLs is requested by a browser or search engine, rewrite it to the form necessary to call your script.
  • Get as many external links as you can updated to use the friendly URLs.

    This search [webmasterworld.com] will lead to dozens of threads on the subject.

    Jim

  • pcgamez

    4:57 am on Feb 17, 2004 (gmt 0)

    10+ Year Member



    what script are you referring to?

    Assume I have no knowledge of anything, because I don't.

    jdMorgan

    5:26 am on Feb 17, 2004 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member



    Script, used loosely here, and covering anything that is not a truly-static page. So, in this case, your php-driven pages must refer to themselves and to your other pages using short, static URLs in their links, and mod_rewrite can then be used to change those back into php page calls including the "id=19041" query strings when a browser or search engine spider requests them.

    Jim

    raytube

    12:07 pm on Mar 11, 2004 (gmt 0)

    10+ Year Member



    Hi there,
    I am basically in the same boat as the originator of this post, just overwhelmed with everything I've read about _mod_rewrite. I have started a thread with my request here:

    [webmasterworld.com...]

    The solution seems to have been that I need to extract parameters from the URL and use them in my PHP script, but surely I could do this without using mod_rewrite by using 'explode' on the URL? I was expecting that mod_rewrite would simply take my static URL (such as 'page/id/10') and using a Rewriterule then provide URL parameters that my PHP script would access just as if I'd used a URL with parameters ('page.php?id=10' for instance).

    Am I wrong in my assumption that this is possible? I hope I have managed to explain this correctly, I realise that it is diffcult to explain what I am trying to achieve!

    I greatly appreciate any insight given!

    Rick

    closed

    4:53 am on Mar 12, 2004 (gmt 0)

    10+ Year Member



    Yes, it is possible, but that's a pretty common request around here, so I'll just have to suggest that you look around for threads on that first, try coding it yourself, then come back here and post that code if you're stuck.

    Whew! Long sentence. Hope it makes sense. :)