Results 1 to 5 of 5
  1. #1
    Newbie
    Join Date
    January 18th, 2005
    Posts
    15
    I was wondering how I could change a URL from a query string to a directory? Example: Change the URL from www.example.net?search=search+string TO www.example.net/search/search+string.
    Thanks

  2. #2
    Full Member
    Join Date
    January 18th, 2005
    Posts
    379
    If you are on a unix server you need to use a mod_rewrite rule in your .htaccess file.

    It may look something like this
    RewriteEngine on
    RewriteRule search/(.*)/ search.cgi?search=$1 [L]

    Search the forums here or google "mod_rewrite search engine friendly url"

  3. #3
    Newbie
    Join Date
    January 18th, 2005
    Posts
    15
    Is it possible to do this without using a .htaccess file?

  4. #4
    ABW Ambassador FFoc's Avatar
    Join Date
    January 18th, 2005
    Posts
    1,015
    If you're using PHP, you can do this without having to rewrite any urls at the server level. PHP has a facility called 'Extra path information' that is available for your use (has been since before 2000, I used it on a project around then).

    The only caveat, IIRC, is that you must call the full script name.

    Ex: <pre class="ip-ubbcode-code-pre">www.somehost.com/search.php/search/some+string</pre>

    The variable $PATH_INFO will contain the string '/search/some+string' which you can break out using something like explode().

    See this document @ zend.com for more details on how to use this.

    [edit:]
    Also note, this facility was copied whole from the same facility in Perl. A Google search for the term 'CGI extra path' will come up with many examples
    ďAn adventure is an inconvenience rightly considered. An inconvenience is an adventure wrongly considered.Ē - G.K. Chesterton

  5. #5
    I like traffic lights
    Join Date
    January 18th, 2005
    Location
    Southern hemisphere - away from Fukushima
    Posts
    2,936
    yes, you don't need to put mod_rewrite rules in an .htaccess file.

    The best location is your apache config file, usually in the virtualhost container for the site in question.

  6. Newsletter Signup

+ Reply to Thread

Similar Threads

  1. Dynamic URLs vs. static URLs
    By Georgie Peri in forum Midnight Cafe'
    Replies: 9
    Last Post: January 30th, 2009, 10:39 PM
  2. Affiliate URLs Vs. Merchant URLs
    By MyDayRegistry in forum Midnight Cafe'
    Replies: 2
    Last Post: March 12th, 2008, 12:25 AM
  3. New format
    By jerseyjim in forum Midnight Cafe'
    Replies: 0
    Last Post: May 3rd, 2005, 11:02 PM
  4. asinsearch.format and grid list format
    By speedcreed in forum Cusimano.com Scripts
    Replies: 1
    Last Post: August 21st, 2003, 09:50 AM
  5. New Format
    By Haiko de Poel, Jr. in forum Midnight Cafe'
    Replies: 36
    Last Post: August 24th, 2002, 01:14 PM

Posting Permissions

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