Results 1 to 13 of 13
  1. #1
    Full Member
    Join Date
    January 18th, 2005
    Location
    Tamborine Mountain Australia
    Posts
    248
    Hi there,

    I'm sure the experts amongst you will be rolling your eyes at this question but here goes -

    I know how to do a mod rewrite in my .htaccess file so that when I put a URL in my browser like this - www.mysites.com/productKAMGPRMC.html it shows the page that is equivalent to
    www.mysites.com/details.php?product=KAMGPRMC

    using something like

    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteRule product(.*)\.html$ /details\.php?product=$1

    My question is - shouldn't mod rewrite show www.mysites.com/productKAMGPRMC.html when the page
    www.mysites.com/details.php?product=KAMGPRMC is generated?

    Or am I completely off track?

  2. #2
    ABW Ambassador CrazyGuy's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,463
    Mmmh - it depends on what you mean by "show" and "generated".

    If you mean, does it work backwards, no it doesn't.

    If you mean shouldn't the "dummy" URL show in the address bar while the "real" page is displayed - yes, that's what I thought.

    ... but maybe you meant soemthing else?


    --------------
    Are you Crazy?

  3. #3
    Intergalactic Trader IGshop's Avatar
    Join Date
    January 18th, 2005
    Posts
    87
    I'm not an expert on this yet, but if you have the link "www.mysites.com/productKAMGPRMC.html" on your page and you click it, Apache will internally change it to "www.mysites.com/details.php?product=KAMGPRMC" but the original link is what will show up in your browser URL address bar.

    Jim

  4. #4
    Full Member
    Join Date
    January 18th, 2005
    Location
    Tamborine Mountain Australia
    Posts
    248
    thanks for your replies - CrazyGuy and IGshop

    <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>Originally posted by CrazyGuyâ„¢:

    If you mean, does it work backwards, no it doesn't.

    <HR></BLOCKQUOTE>

    Yes I guess that's what I did mean.

    Now if it doesn't work backwards, how does it work. For example if somebody did a search on my site using a form and their search produced the following URL http://mysites.com/details.php?search=product+category

    How would you be able to make that into a static URL?

    I guess what I am asking is how without working in reverse does it work without a lot of hand coding to make html links?

  5. #5
    ABW Ambassador swampy_webber's Avatar
    Join Date
    January 18th, 2005
    Location
    West Virginia
    Posts
    698
    Tamborinegal,

    That's what's confusing you I think. You need to fix your php to create the url www.mysites.com/productKAMGPRMC.html instead of
    www.mysites.com/details.php?product=KAMGPRMC
    and mod-rewrites to this so visitors and robots don't see the dynamic url. You can take the same approach on your search page if you want. You wouldn't necessarily have to though since robots won't traverse a search anyway.

    This is just one option. Did I muddle this bad enough?

    Money was never a big motivation for me, except as a way to keep score. The real excitement is playing the game.
    Donald Trump (1946 - ), "Trump: Art of the Deal"

  6. #6
    ABW Ambassador Greg Rice's Avatar
    Join Date
    January 18th, 2005
    Location
    Ohio
    Posts
    4,889
    I've been trying this and can't get it to work. My product detail pages look like this:
    http://www.mysite.com/prod_detail.php?ProdID=100001 and I would like them to be like this (or similar html) http://www.mysite.com/prod_detail100001.html. My .htaccess file looks like this:

    Options +FollowSymLinks
    RewriteEngine on
    RewriteBase /
    RewriteRule prod_detail(.*)\.html$ /prod_detail\.php?ProdID=$1

    I verified mod_rewrite is a loaded module, restarted Apache but it still doesn't work. Does anyone see anything wrong with my .htaccess file or have any ideas what else to check?
    Greg Rice Affiliate Program Management
    www.gocmc.com info(AT)gocmc.com | 330-259-1223

    Join us! - MiNeeds.com | DiscountCandleShop/CheeseSupply | Feng Shui Plaza

  7. #7
    I like traffic lights
    Join Date
    January 18th, 2005
    Location
    Southern hemisphere - away from Fukushima
    Posts
    2,936
    &gt;RewriteRule prod_detail(.*)\.html$ /prod_detail\.php?ProdID=$1

    Try:

    RewriteRule prod_detail(.*)\.html$ /prod_detail.php?ProdID=$1

    (you don't need to escape the '.' in the target)

    If this doesn't work, switch on logging for mod_rewrite and look at the resultant log file.

    The other think I would do is - if the prod ID is always numbers only - get rid of (.*) and use ([0-9]+) instead.

  8. #8
    Intergalactic Trader IGshop's Avatar
    Join Date
    January 18th, 2005
    Posts
    87
    &gt; RewriteRule prod_detail(.*)\.html$ /prod_detail\.php?ProdID=$1

    I would insert a caret before prod_detail thus:

    RewriteRule ^prod_detail(.*)\.html$ /prod_detail\.php?ProdID=$1

    and I agree with Drewbert:

    &gt;if the prod ID is always numbers only - get rid of (.*) and use ([0-9]+) instead.

    Of course to point out something that is not so obvious, you have to generate the URL "http://www.mysite.com/prod_detail100001.html" with your php script and have .htaccess convert it to the php query "http://www.mysite.com/prod_detail.php?ProdID=100001". I didn't realize that at first and the existing documentation seems to assume that you know that already.

    Jim

  9. #9
    ABW Ambassador Greg Rice's Avatar
    Join Date
    January 18th, 2005
    Location
    Ohio
    Posts
    4,889
    Thanks much for the help. Now, I'm really confused. The site is all fed from a database using mysQL and php so all pages are .php except the homepage, which is .html. What I'm trying to accomplish is to have my php pages converted to html so they're indexed in the SEs.

    What confuses me is "you have to generate the URL "http://www.mysite.com/prod_detail100001.html" with your php script" I never heard of this before. If this can be done with php, then why bother with mod_rewrite? If php can do this, do you know where I can get info about this?

    Also, the statement "have .htaccess convert it to the php query "http://www.mysite.com/prod_detail.php?ProdID=100001"". Right now, the product pages are just that "prod_detail.php?ProdID=100001" so I don't understand converting it into a php query when it already is a php query.
    Greg Rice Affiliate Program Management
    www.gocmc.com info(AT)gocmc.com | 330-259-1223

    Join us! - MiNeeds.com | DiscountCandleShop/CheeseSupply | Feng Shui Plaza

  10. #10
    Intergalactic Trader IGshop's Avatar
    Join Date
    January 18th, 2005
    Posts
    87
    Xandman,

    I hear ya!

    You said:
    If this can be done with php, then why bother with mod_rewrite?

    Because your server is going to look for "http://www.mysite.com/prod_detail100001.html" and not find it. Also, no variables are being set. So that's where .htaccess comes into play. It converts the URL above to your php-friendly URL, passes the string "http://www.mysite.com/prod_detail.php?ProdID=100001" to your server, which it finds, the variable $ProdID gets set to "100001" and triggers an action in prod_detail.php.

    Hope that makes it clearer than mud. If not send me a pm and I'll show you some examples from one of my sites.

    Jim

  11. #11
    ABW Ambassador Greg Rice's Avatar
    Join Date
    January 18th, 2005
    Location
    Ohio
    Posts
    4,889
    I just got it. What I was doing wrong was clicking on a product link, which is pulled from the database and displays as prod_detail.php?ProdID=10001 and expecting to see an HTML page. I just read that I need to change my link to that page. So, if I change the link from prod_detail.php?ProdID=&lt;?php echo $L1-&gt;Fields('SKU'); ?&gt; to prod_detail&lt;?php echo $L1-&gt;Fields('SKU'); ?&gt;.html it goes to an HTML page. I assumed it was changing my links to dynamically generated pages to HTML pages on the fly.

    So, since my product links are in one include file, I just needed to change that one include file and, like magic, thousands of HTML pages.

    Thanks so much Jim and Drewbert for all of your help!! I've been pondering this for a few weeks and kept putting it off. I just finished coding this new site and thought I'd try it out before the traffic comes, in case I totally messed something up.

    Do you find this helps much? My problem was Google would index the .php?ProdID=10001 pages but it didn't rank any of them. My hand coded php pages, www.mysite.com/category.php, were indexed and ranked ok but not the ones with a ? in them. Didn't have much luck with WebMerge so started looking for a way to make the thousands of pages, and couple hundred thousand product pages, work since they're already done and represent over a year's work.

    Thanks again, I sure do appreciate it.
    Greg Rice Affiliate Program Management
    www.gocmc.com info(AT)gocmc.com | 330-259-1223

    Join us! - MiNeeds.com | DiscountCandleShop/CheeseSupply | Feng Shui Plaza

  12. #12
    Intergalactic Trader IGshop's Avatar
    Join Date
    January 18th, 2005
    Posts
    87
    Good. Glad you got it.

    I've had a couple datafeed sites deep-crawled by google, both are dynamically generated with php query strings in the URLs. However, the lower level product detail pages were not indexed. It indexed only to the category level. I have a few sites using mod-rewrite which have not been deep-crawled by google, but have been by other crawlers. Time will tell. I'm getting more traffic to these sites from yahoo and ask than I am from google.

    Jim

  13. #13
    ABW Ambassador Greg Rice's Avatar
    Join Date
    January 18th, 2005
    Location
    Ohio
    Posts
    4,889
    Yes, time will tell if tis works good or not with the search engines.

    I was able to change the product links ok but am now stuck on the recordset navigation links. They currently look similar to category.php?pageNum_L1=1&totalRows_L1=446#List or category.php?pageNum_L1=2&totalRows_L1=174#List. Since each recordset is a different size, the link is also different and dependent on the page it's on. So if it's the first page in the recordset pageNum_L1=1, second page pageNum_L1=2 and so on. They also change according to the total number of records "&totalRows_L1=174" and "&totalRows_L1=446" and so on. This makes the ReWrite rule difficult. Do you know if there's a way to account for a variable since I can't write a rule for &totalRows_L1=174 and &totalRows_L1=446 and all the other possibilities.
    Greg Rice Affiliate Program Management
    www.gocmc.com info(AT)gocmc.com | 330-259-1223

    Join us! - MiNeeds.com | DiscountCandleShop/CheeseSupply | Feng Shui Plaza

  14. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Help Mod rewrite
    By womanht in forum Programming / Datafeeds / Tools
    Replies: 4
    Last Post: April 10th, 2007, 10:01 PM
  2. dyse mod-rewrite & FrontPage
    By traffic-tart in forum Cusimano.com Scripts
    Replies: 1
    Last Post: August 21st, 2005, 02:27 PM
  3. Mod Rewrite and Dynamic Titles
    By barb45684 in forum Cusimano.com Scripts
    Replies: 6
    Last Post: June 27th, 2005, 02:29 PM
  4. Mod Rewrite Question
    By swampy_webber in forum Programming / Datafeeds / Tools
    Replies: 2
    Last Post: January 13th, 2004, 04:39 PM
  5. Anyone good with Mod Rewrite?
    By TJ in forum Programming / Datafeeds / Tools
    Replies: 7
    Last Post: November 22nd, 2003, 09:16 AM

Posting Permissions

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