FAQ: mod_rewrite, 301 redirects, and optimizing Apache.

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

  1. iqra_psh

    iqra_psh Active Member

    Messages:
    992
    Likes Received:
    113
    Best Answers:
    0
    Trophy Points:
    85
    #381
    Hello Nintendo,
    The following code added to my hostgator account .htaccess
    what they did ?
    and what its for ?
    and would it hurt any robots SE ?

    # -FrontPage-
    
    IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
    
    <Limit GET POST>
    order deny,allow
    deny from all
    allow from all[CODE]
    Code (markup):
    </Limit>
    <Limit PUT DELETE>
    order deny,allow
    deny from all
    </Limit>
    AuthName www.siteurl.com
    AuthUserFile /home/siteusername/public_html/_vti_pvt/service.pwd
    AuthGroupFile /home/siteusername/public_html/_vti_pvt/service.grp[/CODE]


    Ive change it to the following so it redirects http://site.com to http://www.site.com


    Options +FollowSymLinks
    RewriteEngine on
    RewriteCond %{HTTP_HOST} ^siteurl\.com
    RewriteRule ^(.*)$ http://www.siteurl.com/$1 [R=permanent,L]
    Code (markup):
    Thanks for your help once again Nintendo
     
    iqra_psh, Aug 9, 2006 IP
  2. clover

    clover Peon

    Messages:
    472
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #382
    clover, Aug 12, 2006 IP
  3. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #383
    Looks like front page.

    Is this perl or php? What's the code from the script that changes it to %20? Odds are, where you put that, just changing it to + would do it.

    If the URL works with the space, you probably don't need to change the .htaccess code.
     
    Nintendo, Aug 12, 2006 IP
  4. clover

    clover Peon

    Messages:
    472
    Likes Received:
    25
    Best Answers:
    0
    Trophy Points:
    0
    #384
    jesse,

    the script is perl, amazon apf and i am using your mod rewrite hack.
     
    clover, Aug 13, 2006 IP
  5. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #385
    Post the code you made, over in the APF mod_rewrite board.
     
    Nintendo, Aug 14, 2006 IP
  6. Not Registered

    Not Registered Well-Known Member

    Messages:
    685
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    120
    #386
    Not sure if this is the right place to post it, but I still hope...


    We used Site1 and Site2 with one domain.
    Since it is considered as black hat, we separated the sites:
    Now Site1 is our major site,
    And Site2 has homepage only.

    The problem is that now Site2 has OLD pages with PR on Google,
    and we are starting to loose them (404 - page not found)

    What is the best way to not loose the site2 pages on search engines?
    After all, we'd want them to point to our major site!

    Please note that the pages are dynamic:
    http://www.domain.com/index.php?opti...d=12&Itemid=10


    Many thanks!
     
    Not Registered, Aug 14, 2006 IP
  7. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #387
    Redirect everything to the new domain. Something like

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^(.*)$ http://www.newdomain.com/$1 [R=301,L]
     
    Nintendo, Aug 15, 2006 IP
  8. Not Registered

    Not Registered Well-Known Member

    Messages:
    685
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    120
    #388
    Thank you :)
     
    Not Registered, Aug 15, 2006 IP
  9. Netbridge

    Netbridge Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #389
    I have chaned all my file names from dashes to underscore.

    www.inetbridge.net/driver/asus-mb-23.html

    I need to change this to

    www.inetbridge.net/driver/asus_mb_23.html


    Can this be done?


    Thanks
     
    Netbridge, Aug 26, 2006 IP
  10. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #390
    Bad move!! Even Google has said -'s are better than _'s!!

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /driver/
    RewriteRule ^([^.]+)\-([^.]+)\-([^.]+)\-([^.]+)\.html$ http://www.inetbridge.net/$1_$2_$3_$4.html [R=301,L]
    RewriteRule ^([^.]+)\-([^.]+)\-([^.]+)\.html$ http://www.inetbridge.net/$1_$2_$3.html [R=301,L]
    RewriteRule ^([^.]+)\-([^.]+)\.html$ http://www.inetbridge.net/$1_$2.html [R=301,L]
     
    Nintendo, Aug 26, 2006 IP
  11. Netbridge

    Netbridge Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #391
    Thanks! :D
     
    Netbridge, Aug 27, 2006 IP
  12. mgrohan

    mgrohan Active Member

    Messages:
    671
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    58
    #392
    mgrohan, Sep 7, 2006 IP
  13. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #393
    domain.com/.htaccess

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^directory/Food/Page([^.]+)\.htm$ directory/Food/index.php?p=$1 [L]

    Change index.php to what ever the index file is.
     
    Nintendo, Sep 7, 2006 IP
  14. potter

    potter Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #394
    Hi,

    I have my url like this at the moment:
    www.mydomain.com/index.php?show=2&go=sidor/boka.php&page_id=31&lang=se

    and wounder how should my .htaccess file look like?

    I have all my pages stored in directory "sidor" so next question is where should I put the .htaccess file?
     
    potter, Sep 8, 2006 IP
  15. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #395
    How do you want the URLs to look!!
     
    Nintendo, Sep 8, 2006 IP
  16. potter

    potter Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #396
    I would like the url to be:
    www.mydomains.com/sidor/boka.php/lang/se

    but I don't now if thats possible?

    Otherwise maybe:
    www.mydomains.com/index/show/2/go/sidor/boka/page_id/31/lang/se

    Or if you can give me some examples. For your knowledges I have a database connected to my site and show is driven my menu, go decide the page, page_id the content and last is lang who decide english or swedish.
     
    potter, Sep 8, 2006 IP
  17. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #397
    The show and page ID numbers would probably need to be in the URL.

    mydomains.com/index/show/2/go/sidor/boka/page_id/31/lang/se


    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^index/show/([^.]+)/go/([^.]+)/page_id/([^.]+)/lang/([^.]+)$ index.php?show=$1&go=$2&page_id=$3&lang=$4 [L]
     
    Nintendo, Sep 8, 2006 IP
  18. potter

    potter Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #398
    Where should I put the .htaccess file?
    Do I need to change my index.php to call this file?
     
    potter, Sep 8, 2006 IP
  19. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #399
    domain.com/.htaccess

    index file doesn't need touched. mod_rewrite just makes fake URLs work.
     
    Nintendo, Sep 8, 2006 IP
  20. potter

    potter Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #400
    Doesn't work, my url is the same as before
     
    potter, Sep 8, 2006 IP