FAQ: mod_rewrite, 301 redirects, and optimizing Apache.

Discussion in 'Apache' started by Nintendo, Jul 30, 2005.

  1. Xuxa

    Xuxa Banned

    Messages:
    248
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #681
    I want both to work.
     
    Xuxa, Jun 29, 2007 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #682
    Then you have them listed both with and with out the /.
     
    Nintendo, Jun 29, 2007 IP
  3. Xuxa

    Xuxa Banned

    Messages:
    248
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #683
    Ok, thanks.

    Is there anyway to type in a .htaccess file without messing up the code?

    For instance, in php you will do "// Text"

    In the .htaccess file I tried "<text>" and it didn't work? But, when I try to seperate my code with the <text> I get an internal Server Error?
     
    Xuxa, Jun 29, 2007 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #684
    Start the line with #
     
    Nintendo, Jun 30, 2007 IP
  5. Xuxa

    Xuxa Banned

    Messages:
    248
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #685
    thank you! :D
     
    Xuxa, Jul 5, 2007 IP
  6. Jona

    Jona Well-Known Member

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #686
    Jona, Jul 8, 2007 IP
  7. kks_krishna

    kks_krishna Active Member

    Messages:
    1,495
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    80
    #687
    kks_krishna, Jul 8, 2007 IP
  8. EGGENZ

    EGGENZ Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #688
    this is my THANKYOU Mr. super nenna
    Im still confused on the whole topic but i have some great friends that helped me out

    (had to change the php code what-cha-mah-call-its aswell :confused: )

    well it worked and im happy for the moment :0

    so thanks once again

    EEGGENZ 2007
     
    EGGENZ, Jul 9, 2007 IP
  9. Jona

    Jona Well-Known Member

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #689
    I got my url's re-written okay. But now I have exactly same problem as you!
    If you or anyone else have/find a solution, pls post it here.
    This is how it looks for me:

    www.website.com/product/seller.html
    And it become like this when I post:
    www.website.com/product/seller.html?k=product&s=seller

    How to avoid "?k=product&s=seller" is added at end of url?
    Guess something need to be done in the php code ... But what ?
    To start with, shall we use POST or GET ?
     
    Jona, Jul 9, 2007 IP
  10. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #690
    What does the link code look like in the script?

    domain.com/$k/$s.html

    is how it should look. Having the full domain in the link code might fix it. Links have to be as if the URLs are real. The browsers have no idea you're using mod_rewrite.
     
    Nintendo, Jul 9, 2007 IP
  11. Jona

    Jona Well-Known Member

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    110
    #691
    Nintendo, this is my form code:

     
     <form name="SearchForm" method="get">
      <input name="k" type="text" size="21" value="<? print $keywords; ?>"><br>
      <input name="s" type="text" size="21" value="<? print $seller;   ?>"><br>
      <input type="submit" value="Search"><br>
     </form>
    
    Code (markup):
    Normal link is easy to make correct:
    http://www.mysite.com/<? print $k; ?>/<? print $s; ?>"
    Code (markup):
    The big problem is the FORM code above ... Any idea how to get that working also ?
     
    Jona, Jul 9, 2007 IP
  12. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #692
    Search engines don't use forms, so they wouldn't ever seen the form results page. I only know how to make forms spit out static URLs in perl.
     
    Nintendo, Jul 9, 2007 IP
  13. Pammer

    Pammer Notable Member

    Messages:
    3,417
    Likes Received:
    397
    Best Answers:
    0
    Trophy Points:
    260
    #693
    suppose i have site which have many sub domains... and i just want to redirect to non www to with "WWW.domainname.con" but thats way my sub domain name also getting like "WWW.subdomainname.domainname.con" which i dont want... shall i put different to each and every folder OR WE have some another rewrite rules for that ?
     
    Pammer, Jul 13, 2007 IP
  14. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #694
    I think you need a .htaccess file at each sub-domain.

    subdomainname.domainname.con/.htaccess
     
    Nintendo, Jul 13, 2007 IP
  15. Pammer

    Pammer Notable Member

    Messages:
    3,417
    Likes Received:
    397
    Best Answers:
    0
    Trophy Points:
    260
    #695
    yeah, i guessed that, but its such a pain to do all by manually if each 12 sites have a 13 subdomain name !

    Though, thanks for clarify.
     
    Pammer, Jul 14, 2007 IP
  16. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #696
    Hello,
    Does rewrite work for links in rss feeds that have been parsed into html?
    For example, http://caboosh.org/youtube.php?query=cooking
    I'm trying to rewrite the urls in the "keywords", so that the keyword will run through my search script.
    So far I cannot get it to work.
    Could you help me?
     
    Luke Jones, Jul 14, 2007 IP
  17. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #697
    I only know how to make the URL after using a form, be static, in perl.
     
    Nintendo, Jul 14, 2007 IP
  18. lummer

    lummer Active Member

    Messages:
    221
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    81
    #698
    Could someone please help me to redirect the following?

    All urls..

    http://www.domain.com/product.php?refid=298
    http://www.domain.com/product.php?refid=298&lang=language
    http://www.domain.com/prodduct.php?refid=298
    http://www.domain.com/prodduct.php?refid=298&lang=language


    to either

    http://www.domain.com/product/refid-language.html
    or
    http://www.domain.com/product/refid.html (if there is no lang=language)

    and also to make sure that any current links to the old URL's are 301'd to the new ones?
     
    lummer, Jul 17, 2007 IP
  19. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #699
    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^prodducts/([^.]+)\-([^.]+)\.html$ prodduct.php?refid=$1&lang=$2 [L]
    RewriteRule ^product/([^.]+)\-([^.]+)\.html$ product.php?refid=$1&lang=$2 [L]
    RewriteRule ^prodducts/([^.]+)\.html$ prodduct.php?refid=$1 [L]
    RewriteRule ^product/([^.]+)\.html$ product.php?refid=$1 [L]

    Each script would have to have it's own fake for example directory. For example prodducts and product.
     
    Nintendo, Jul 17, 2007 IP
  20. Luke Jones

    Luke Jones Peon

    Messages:
    427
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #700
    Hello,
    If I'm using Get commands to take the url or the search query from the url, would using such a rewrite stop this working?
    Or do I have to alter the Get command?

    Thanks.
     
    Luke Jones, Jul 18, 2007 IP