PassMark Logo
Home » Forum

Announcement

Collapse
No announcement yet.

Using Mod_rewrite With Zoom Search Engine

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using Mod_rewrite With Zoom Search Engine

    I want to incorporate mod_rewrite to make use of a rotator file that contains links for various keyword phrases. Thus I can add a few new pages of content to my site (on the fly) using the search results generated.

    In other words, turn a query like this:

    PHP Code:
    www.mywebsite.net/meso-search.php?zoom_query=alternative+cancer+cure 
    ...into a static URL like one of these:

    PHP Code:
    www.mywebsite.net/alternative-cancer-cure
    www
    .mywebsite.net/alternative-cancer-cure.php 
    All files on the site are in .php and a static link in the rotator would be:

    PHP Code:
    "/alternative-cancer-cure.php">Alternative Cancer Cure</a
    ...and again the objective is to elicit a search results page by clicking on one of the links.

    The site's template, the rotator script and Zoom are in place and working. I believe all that's needed is the mod_rewrite. Hopefully I could also use it to add matching titles, heading tags, etc. as needed.

    This is what I'm attempting to use now, though it has no effect on the URLs:

    PHP Code:
    RewriteEngine On
    RewriteRule 
    ^([^-]*)\.php$ /meso-search.php?zoom_query=$[L
    Any suggestions would be appreciated.

    .

  • #2
    I think you'll find this previous discussion helpful:
    http://www.wrensoft.com/forum/showthread.php?t=34
    --Ray
    Wrensoft Web Software
    Sydney, Australia
    Zoom Search Engine

    Comment


    • #3
      Originally posted by Ray View Post
      I think you'll find this previous discussion helpful:
      http://www.wrensoft.com/forum/showthread.php?t=34
      Yeah I read that one earlier today -- er, yesterday. Just thought I'd post another Zoom mod_rewrite and see if anyone else has done something similar.

      There's a couple of other sites I'm investigating now:

      http://www.mod-rewrite-wizard.com/
      http://www.modrewrite.com/

      ...the latter has a mod_rewrite forum with quite a large number of posts on the subject.

      .

      Comment


      • #4
        It seems to me that the example given (by iantresman) in the previous thread should allow you to do what you are after. I'm not sure what you are missing or looking for? Is there a particular problem you are having?
        --Ray
        Wrensoft Web Software
        Sydney, Australia
        Zoom Search Engine

        Comment


        • #5
          Originally posted by Ray View Post
          It seems to me that the example given (by iantresman) in the previous thread should allow you to do what you are after. I'm not sure what you are missing or looking for? Is there a particular problem you are having?
          First of all I'm not using the cgi version install and secondly I have no .html extension pages. I'm using php files. Other than that, I did try his code tweaking it for my site and I got a 500 Internal Server error.

          Please re-read the original post above for what I want to do.

          Thanks

          Comment


          • #6
            What about at being able to elicit title and heading tags on the page after a search is performed; is that possible?

            As I look through the code from other sites I own, I see where one of the previous programmers had used an include to echo a particular query in the various spots where needed.

            examples:
            Code:
            <html>
            <head>
            <title>[COLOR="DarkRed"]<?php echo $term; ?>[/COLOR]</title>
            
            <h1>[COLOR="DarkRed"]<?php echo $term; ?>[/COLOR]</h1>
            All Zoom search results already display the term searched on the results pages. Surely there must be something relative to the above in Zoom's search.php code that could be used to create titles and heading tags on the results pages.

            While I'm not a programmer, Zoom's search.php code looks like it uses print functions similar to javascript. Would there be a way to somehow incorporate $query so that it would call the searched term and add it where I want?

            Maybe something like this?
            Code:
            <title><?php print("$query"); ?></title>
            What about editing search.php?
            Code:
            //Print heading
            print("<div class=\"searchheading\">" . $STR_RESULTS_FOR . " " . $queryForHTML);
            if ($UseCats)
            {
                if ($cat[0] == -1)
                {
                    print(" " . $STR_RESULTS_IN_ALL_CATEGORIES);
                    $query_zoom_cats = "&amp;zoom_cat&#37;5B%5D=-1";
                }
                else
                {
                    print(" " . $STR_RESULTS_IN_CATEGORY . " ");
                    for ($catit = 0; $catit < $num_zoom_cats; $catit++)
                    {
                        if ($catit > 0)
                            print(", ");
                        print("\"". rtrim($catnames[$cat[$catit]]) . "\"");
                        $query_zoom_cats .= "&amp;zoom_cat%5B%5D=".$cat[$catit];
                    }
                }
            }
            print "<br /><br /></div>\n";
            
            print "<div class=\"results\">\n";
            Could a language construct such as echo(), print(), include(), or require() be added to the code above (or another area) to call the $query so as to print to placeholders within the page titles and heading tags?

            In other words, since value=\"".htmlspecialchars($query)."\" is printing the searched term to the form's field, how could this be exploited for my needs?

            Thanks for any advice.
            Last edited by zoomology; Jul-21-2007, 07:06 AM.

            Comment


            • #7
              A thought...

              Because <?php include("search.php"); ?> starts in the middle of my custom php search template (below the initial body tag) would any attempt to include the query term in HTML titles, meta tags, heading tags, etc. (above the include) be futile?

              To avoid any confusion, please note that I am not referring to the search results displayed. I am interested in showing HTML titles and HTML heading tags on my website for a given search. That is, the <title> of a page is displayed at the top of your computer monitor.

              At minimum, please let me know whether you think this is possible or not, so I won't waste anymore time on it.

              Thanks
              Last edited by zoomology; Jul-21-2007, 07:38 AM.

              Comment


              • #8
                I seemed to have answered my own question. Using a custom php template, the Zoom search engine is unable to generate titles and/or heading tags for a given search since the <?php include("search.php"); ?> is placed below where those would appear in an HTML document.

                Although it doesn't accomplish what is needed, one can print on the results page of a particular query the searched term by placing <?php print "$query"; ?> in the template file, so long as it's below the search.php include.

                I still haven't established though whether it's completely impossible to use <?php print "$query"; ?> to create titles. Someone else may know how to code the template to facilitate the task.

                ...feedback appreciated.

                Comment


                • #9
                  What you are asking for, as you should be well aware, requires custom scripting and programming to achieve. However, you have stated yourself that you are not experienced in this area and that you are not a programmer.

                  I'm afraid that there's no simple answer to most of your questions, except perhaps that you should seek a programmer to consult regarding the functionality that you wish to code on your site. That, or start investing some time in learning programming/scripting (which means beginning with simpler code and then coming back to this task once you're more prepared). I don't mean this in any derogatory way - all developers started at this stage, but it seems clear to me that you are in over your head with the changes you wish to apply.

                  Programming and scripting depends heavily on the context of the code and there is no magic receipe that I can give you, or that you can cut+paste and can be guaranteed it will work. In some very simple cases, there may be small changes that are possible with this cut+paste method, and this misleads many beginning web developers to think that all sorts of changes should be possible if they can just find the magic words to put in the right place.

                  I'll try to answer your questions where possible:

                  Originally posted by zoomology View Post
                  First of all I'm not using the cgi version install and secondly I have no .html extension pages. I'm using php files. Other than that, I did try his code tweaking it for my site and I got a 500 Internal Server error.
                  There is little difference with the use of the rewrite rule as to whether you use the CGI version or PHP version, etc. The only difference is that the rule would change where it should obviously need to, for your site: e.g. where it says "search.cgi", yours might be "search.php". If you are not familiar enough with rewrite URL rules to understand the syntax however, you should consult the Apache Rewrite URL documentation. There are also tutorial links given in that previous forum thread.

                  Originally posted by zoomology View Post
                  A thought...

                  Because <?php include("search.php"); ?> starts in the middle of my custom php search template (below the initial body tag) would any attempt to include the query term in HTML titles, meta tags, heading tags, etc. (above the include) be futile?
                  Yes, to a point. For what you want to do, you shouldn't be modifying our "search.php" script. Not only is it not going to work for what you wish to achieve in your particular scenario (where you have a <head> ... </head> output prior to the search.php's output), it's also a complex script that you risk breaking functionality with your changes.

                  In your case, you should really be looking at adding some scripting to your own PHP page (which is now embedding the search.php page). This functionality should be entirely independent of Zoom. What it needs to do is pickup the search query from the parameters in the URL, before it displays the <title> tag, and format the search query for displaying in the title.

                  Originally posted by zoomology View Post
                  At minimum, please let me know whether you think this is possible or not, so I won't waste anymore time on it.
                  It is certainly possible, but I would recommend getting a programmer to do it if you are not experienced with PHP scripting. While we like to help where we can, note however, that these questions are now all unrelated to Zoom. Instead, they are strictly usage/implementation questions regarding Apache Rewrite URL and using PHP scripting to add page titles based on HTTP GET parameters. But I hope the above tips are of help.
                  --Ray
                  Wrensoft Web Software
                  Sydney, Australia
                  Zoom Search Engine

                  Comment


                  • #10
                    Mission Accomplished

                    Since I really like Zoom's convenience, functions and easy installation, I continued to pursue a solution; a fella on another forum provided the mods and code tweaks I needed. I was able to provide enough information from my "wish list" for him to figure it out in seconds. Below is the fix for anyone else wanting the same results.

                    The following was added to the .htaccess file. Note that mywebsite.net is changed to my own domain and support.php is my template filename. Adding the mod_rewrite rules allow me to link to a specific keyword search that uses a more search engine friendly URL. The + sign was left in place so as not to interfere with Zoom's other algos.

                    example: <a href="/asbestos+dust.php">asbestos dust</a>

                    Code:
                    <FilesMatch "\.(php|html?)$"> 
                       php_value zlib.output_compression 4096 
                    </FilesMatch> 
                     
                    <Files /> 
                       ForceType application/x-httpd-php 
                    </Files> 
                     
                    php_flag allow_url_fopen on 
                    php_value allow_call_time_pass_reference 1 
                     
                    Options +FollowSymLinks 
                    ErrorDocument 404 http://www.mywebsite.net 
                     
                    RewriteEngine On 
                     
                    RewriteCond %{HTTP_HOST} !^www\.mywebsite\.net [NC] 
                    RewriteRule ^(.*)$ http://www.mywebsite.net/$1 [R=301,L] 
                     
                    RewriteCond %{SCRIPT_FILENAME} !-f 
                    RewriteRule ^([^/]+)\.php$ /support.php?zoom_query=$1 [L]


                    The below is added inside the <title> and <h1> tags to generate the searched term in those areas of my template.

                    Code:
                    <title><?php echo htmlentities($_GET['zoom_query'], ENT_QUOTES); ?></title>
                     
                    <h1><?php echo htmlentities($_GET['zoom_query'], ENT_QUOTES); ?></h1>

                    With a little effort, everything's working okay now and I'm a happy camper . If I were you, I'd probably consider modifying future versions of Zoom to enable search term generation in the results page titles, or at minimum provide a brief tutorial offering suggestions based on my experience.

                    In any event, it's been fun -- have a nice day -- and remember, 911 was an inside job.
                    .

                    Comment


                    • #11
                      In hindsight I forgot to mention the website, just in case someone wants to see Zoom and mod_rewrite in action.

                      > searchmesothelioma(dot)net

                      ...the friendly URLs are located at /information.php

                      .

                      Comment

                      Working...
                      X