htaccess on localhost?

Discussion in 'PHP' started by adamjblakey, Oct 1, 2008.

  1. #1
    Hi,

    I am working off local host and i want to use htaccess but i am unsure on the code that i would need.

    This is my normal re-write rule for a domain like e.g http://www.bob.com/info..php

    
    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9-_]+)\.html$ info.php?title=$1
    
    Code (markup):
    But on local host the url is: http://localhost/xampp/websites/site1/info.php so what would i put in the htaccess file for this?

    I was thinking something like this but it does not work;

    
    RewriteEngine On
    RewriteRule ^([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_]+)/([a-zA-Z0-9-_]+)\.html$ info.php?cat=$1&item=$2&other_item=$3&title=$4&others_items=$5
    
    Code (markup):
    Cheers,
    Adam
     
    adamjblakey, Oct 1, 2008 IP
  2. Clive

    Clive Web Developer

    Messages:
    4,507
    Likes Received:
    297
    Best Answers:
    0
    Trophy Points:
    250
    #2
    Try this:
    
    RewriteEngine On
    RewriteBase /xampp/websites/site1/
    RewriteRule ^([a-zA-Z0-9-_]+)\.html$ info.php?title=$1
    
    Code (markup):
     
    Clive, Oct 1, 2008 IP
  3. adamjblakey

    adamjblakey Active Member

    Messages:
    1,121
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    80
    #3
    thank you for your reply, i have tried that but it does not seem to work?

    I just get the following error:

    
    Server error!
    
    The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.
    
    If you think this is a server error, please contact the webmaster.
    Error 500
    localhost
    10/01/08 10:12:34
    Apache/2.2.2 (Win32) DAV/2 mod_ssl/2.2.2 OpenSSL/0.9.8b mod_autoindex_color PHP/5.1.4 
    
    Code (markup):
     
    adamjblakey, Oct 1, 2008 IP
  4. Clive

    Clive Web Developer

    Messages:
    4,507
    Likes Received:
    297
    Best Answers:
    0
    Trophy Points:
    250
    #4
    I have done it on my end with a joomla script that I got installed and available for testing, it seems to be working fine.
    (Note that I updated the code in my post once so maybe you caught the old one).
     
    Clive, Oct 1, 2008 IP
  5. alhelalat

    alhelalat Member

    Messages:
    56
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #5
    make sure the Apache version you are using support rewrite mode
    check Apache config file httpd.config
    find this line
    #LoadModule rewrite_module modules/mod_rewrite.so
    and remove the hash key to be this way
    LoadModule rewrite_module modules/mod_rewrite.so
    last step find this line
    # This should be changed to whatever you set DocumentRoot to.
    under this line search for #AllowOverride All
    remove the hash key to be this way AllowOverride All
    that is it
    you are done
     
    alhelalat, Oct 1, 2008 IP