FAQ: mod_rewrite, 301 redirects, and optimizing Apache.

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

  1. EGS

    EGS Notable Member

    Messages:
    6,078
    Likes Received:
    438
    Best Answers:
    0
    Trophy Points:
    290
    #641
    EGS, May 30, 2007 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #642
    Nintendo, May 30, 2007 IP
  3. EGS

    EGS Notable Member

    Messages:
    6,078
    Likes Received:
    438
    Best Answers:
    0
    Trophy Points:
    290
    #643
    EGS, May 31, 2007 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #644
    Real men use mod_rewrite and not redirect! :D
     
    Nintendo, Jun 1, 2007 IP
  5. EGGENZ

    EGGENZ Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #645
    Hey peeps im in need of some help as i cant afford to pay anyone anymore to work on my website

    I know little about web development but am learning pretty quick...

    here is my dielmma...

    my website pages eg...

    http://www.domain.com/listing.php?Catid=3&cityname=16

    where cityname=16 sydney
    where Catid=3 Food

    http://www.mepg.com.au/Food/Sydney

    Is this Possible whith this method in this thread or is there another i have to look at

    Please any help is greatly appreciated

    Thankyou in advance

    and VWD Nintendo for your contributions
     
    EGGENZ, Jun 2, 2007 IP
  6. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #646
    The numbers would have to be in the URL, and you would have to know php enough to search and replace to get rid of spaces and special characters.
     
    Nintendo, Jun 2, 2007 IP
  7. EGGENZ

    EGGENZ Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #647
    if it is easy enough and/or if its possible to do could you please do one line of example text

    if not no harm ill keep searching im constantly learning as i search :)

    thanks once again
     
    EGGENZ, Jun 2, 2007 IP
  8. EGGENZ

    EGGENZ Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #648
    PS sorry i only got 2 posts but please be gentle
     
    EGGENZ, Jun 2, 2007 IP
  9. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #649
    mepg.com.au/3/Food/16/Sydney

    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)/([^.]+)/([^.]+)/([^.]+)$ listing.php?Catid=$1&cityname=$3 [L]
     
    Nintendo, Jun 2, 2007 IP
  10. EGGENZ

    EGGENZ Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #650
    Once again i appreciate your help Nintendo ive used the above code and does not work :(

    please dont get me wrong im still reading and learning and belive me the code u used above is way advanced compared to what im up to but getting there

    my site does accept the mod_rewrite (test on page one worked)

    if it helps and only if u dont mind (it might help others aswell as me)

    my web address is http://www.mepg.com.au/ click on the city/cuisine buttons to get an idea for what im up against

    Thanks in advance EGGENZ
     
    EGGENZ, Jun 2, 2007 IP
  11. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #651
    It doesn't change the links. You would have to know how to for example make the links link to

    mepg.com.au/3/Food/16/Sydney
     
    Nintendo, Jun 2, 2007 IP
  12. EGGENZ

    EGGENZ Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #652
    well i can honestly say im confused :(

    i cant even get the most basic code to work (exclude. test code)

    im still looking and reading and with time ill get there...

    but still if anyone has any ideas or help its much appreciated..

    PS I liked the sound of expats idea


    (e.g.
    mypage.php?subject=How_to_do_mod_rewrite

    RewriteRule subject_([A-zA-Z_]+).htm page_detail.php?subject=$1 [L]

    could give you a translatable static htm like

    mmydomain.xxx/subject_how_to_do_mod_rewrite.htm

    in your php you can than look up the content for the titel instead of using page id
    )

    but the basics arnt working for me yet so dont worry im not getting ahead of myself its for future use :)

    all the best EGGENZ
     
    EGGENZ, Jun 3, 2007 IP
  13. EGGENZ

    EGGENZ Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #653
    Hey im back ive been reading heaps and found tons of informaton but one mod i was reading (the one i hope) recomended me to edit the httpd.conf file. 1 problem i dont/cant find one :( as the site im reading off has no forum and this is the only decent forum ive found on the topic (and helpful) could someone please help me with httpd.conf file should i create one??? is it a text file ??? thankyou V/M [L]
     
    EGGENZ, Jun 3, 2007 IP
  14. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #654
    Nintendo, Jun 4, 2007 IP
  15. Sh0gUn

    Sh0gUn Active Member

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    86
    #655
    I have a host with ssl certificate and dedicated IP. I need some help on the following example.

    http://www.domain_name.com/folder/ rewrite to 404.php
    https://www.domain_name.com/folder/ rewrite to 404.php
    http://101.101.101.101/ rewrite to forbidden.php
    https://101.101.101.101/ rewrite to forbidden.php

    Thanks for your advice.
     
    Sh0gUn, Jun 4, 2007 IP
  16. movingconcierge

    movingconcierge Well-Known Member

    Messages:
    550
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    110
    #656
    I need help turning this:
    /index.php?Action=Show&Node=14219061&ItemPage=1
    Code (markup):
    into this:

    /keyword-nodename.php
    Code (markup):
    I've honestly tried to read this stuff, but I'm old and feeble and I am just confused. :)

    Any help would be GREATLY appreciated.
     
    movingconcierge, Jun 16, 2007 IP
  17. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #657
    movingconcierge, not exactly sure but is this what you want?
    RewriteEngine on
    RewriteBase /
    RewriteRule ^(.+)-(.+)\.php$ index.php?Action=$1&Node=$2&ItemPage=1 [L]
    Code (markup):
    Or maybe this:
    RewriteEngine on
    RewriteBase /
    RewriteRule ^keyword-(.+)\.php$ index.php?Action=Show&Node=$1&ItemPage=1 [NC,L]
    Code (markup):
     
    krt, Jun 16, 2007 IP
  18. movingconcierge

    movingconcierge Well-Known Member

    Messages:
    550
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    110
    #658
    Thanks, krt.

    When I went into my .htacess file I found this:

    AddType application/x-httpd-php5 php
    
    RewriteEngine On
    RewriteRule ^index.html$ index.php
    
    RewriteRule ^(.*)/(.*)-search-(.*)-(.*)-(.*).html index.php?Operation=ItemSearch&SearchIndex=$1&$2=$3&Sort=$4&ItemPage=$5 [QSA,L]
    RewriteRule ^(.*)/(.*)-search-(.*)-(.*).html index.php?Operation=ItemSearch&SearchIndex=$1&$2=$3&Sort=$4 [QSA,L]
    RewriteRule ^(.*)/(.*)-search-(.*).html index.php?Operation=ItemSearch&SearchIndex=$1&$2=$3 [QSA,L]
    RewriteRule ^(.*)/browse-(.*)-(.*)-(.*).html index.php?Operation=ItemSearch&SearchIndex=$1&BrowseNode=$2&Sort=$3&ItemPage=$4 [QSA,L]
    RewriteRule ^(.*)/browse-(.*)-(.*).html index.php?Operation=ItemSearch&SearchIndex=$1&BrowseNode=$2&Sort=$3 [QSA,L]
    RewriteRule ^(.*)/browse-(.*).html index.php?Operation=ItemSearch&SearchIndex=$1&BrowseNode=$2 [QSA,L]
    RewriteRule ^(.*)/(.*).html index.php?Operation=ItemLookup&ItemId=$1 [QSA,L]
    RewriteRule ^(.*).html?$ index.php?SearchIndex=$1 [QSA,L]
    
    
    Code (markup):
     
    movingconcierge, Jun 16, 2007 IP
  19. movingconcierge

    movingconcierge Well-Known Member

    Messages:
    550
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    110
    #659
    Anyone lend a hand? I'd hand out some green! :D
     
    movingconcierge, Jun 18, 2007 IP
  20. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #660
    Do you know how to edit the script to link like that, with the special characters taken out?
     
    Nintendo, Jun 18, 2007 IP