1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

FAQ: mod_rewrite, 301 redirects, and optimizing Apache.

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

  1. internetstromer

    internetstromer Member

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #841
    I have successfully implented the code on my entire php + MySql Database driven site it has approx 75000 pages my .htaccess code is around 30 lines.

    But the main issue is that when I open more than 4 to 5 page at same time my server load is raising more than 7 to 8 and some time my entire server get stuck up I don't know how to tackle with that cna you help on this?

    Current apache settings which I have

    <IfModule prefork.c>
    StartServers 110
    MinSpareServers 75
    MaxSpareServers 125
    MaxClients 900
    ServerLimit 900
    MaxRequestsPerChild 0
    </IfModule>

    other settings
    ServerLimit 1024
    KeepAlive On
    MaxKeepAliveRequests 50
    KeepAliveTimeout 1

    Please help
     
    internetstromer, Mar 18, 2009 IP
  2. SupaSharp

    SupaSharp Well-Known Member

    Messages:
    1,865
    Likes Received:
    74
    Best Answers:
    0
    Trophy Points:
    100
    #842
    Found this post in google. Thanks! Helped a lot
     
    SupaSharp, Apr 30, 2009 IP
  3. cormack2009

    cormack2009 Peon

    Messages:
    177
    Likes Received:
    3
    Best Answers:
    1
    Trophy Points:
    0
    #843
    If i have a site: site.com

    and i want to redirect to index.php sending the complete url writen?

    If user typw site.com/anything/else/another/file.php

    or whatever i get the full path that the user try to get, how can this be done?
     
    cormack2009, May 1, 2009 IP
  4. internetstromer

    internetstromer Member

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #844
    STILL WAITING FOR THE REPLY :mad:
     
    internetstromer, May 19, 2009 IP
  5. KlearConcepts

    KlearConcepts Peon

    Messages:
    349
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #845
    How would I rewrite a sub-domain like this.

    I want to redirect secure.nixism.com to my.nixism.com.

    How would I do that?
     
    KlearConcepts, May 21, 2009 IP
  6. malc

    malc Peon

    Messages:
    129
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #846
    First time using mod_rewrite and would really appreciate some help.

    I am using:
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^([a-zA-Z0-9_-]+)/([0-9]+)\.html$ searchresult.php?cat_id=$2[L]
    RewriteRule ^madeupword/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ article.php?art_id=$2[L]
    Code (markup):
    This make the links work like this:
    [url]http://www.mysite.com/Pasta-articles/24.html[/url]
    [url]http://www.mysite.com/madeupword/How-to-pasta/581.html[/url]
    Code (markup):
    This seems to work fine but the problem is, my url's are generated dynamically and for me to change them to static links there are spaces between the words.
    So the static link looks like this:
    [url]http://www.mysite.com/Pasta%20articles/24.html[/url]
    Code (markup):
    Instead of this:
    [url]http://www.mysite.com/Pasta-articles/24.html[/url]
    Code (markup):
    How can I change this code to replace a space(%20) with a dash(-)?
     
    malc, Jun 23, 2009 IP
  7. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #847
    The script has to do the change, like a search and replace there. The script makes the links. mod_rewrite only makes the URLs work.
     
    Nintendo, Jun 23, 2009 IP
  8. vasyl

    vasyl Peon

    Messages:
    138
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #848
    Try \- instead of just -
     
    vasyl, Jun 24, 2009 IP
  9. malc

    malc Peon

    Messages:
    129
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #849
    Thanks Nintendo and vasyl ;)

    Yes I hade to change the link in my site's script. Lucky it's all templates so you only need to change it in a few places. This is how I created the link for one of the pages:
    Next I'll try out your query string examples. It's a great tutorial thank you.

    What I would really like is a even cleaner url like what WBseo does.:
    www.yoursite.com/general-chat/ (category)
    and
    www.yoursite.com/general-chat/hello-people/(post inside category)
     
    malc, Jun 24, 2009 IP
  10. @SHFAQ

    @SHFAQ Well-Known Member

    Messages:
    257
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #850
    I want to transfer from old domain to new domain with 301 redirect but dont know much about .htaccess codes so plz help me and tell me the way and code that i dont lose users and search engine traffic.
    I want to transfer many section (folders) and files to new domain but wanna use index and some section (folder) remain active on old domain so plz tell me

    1: How to redirect folders and php and html file to new domain ? plz remember that i will upload all files and folders on new domain with same structure, names and extension as on old domain.

    2: What code to put in .htaccess to remain active some section folders and files with php and html extension on old domain ?

    3: If i have 100+ php and html files in root and wanna 301 redirect all to new domain but remain index file on odl domain with same name and extension and structure then what code to use to redirect all files to new domain but index remain active on old domain ?
     
    @SHFAQ, Jun 27, 2009 IP
  11. lektrikpuke

    lektrikpuke Well-Known Member

    Messages:
    297
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    113
    #851
    I have seen it load down a server by as much as 30%, but that was in an extreme (and dumb) case. We (I won't say where) had thousands of rewrite conditions and rules in our .htaccess file. Once we made generalized rules and trimmed the number of rules to a reasonable amount, the server load dropped to nill.
     
    lektrikpuke, Jun 28, 2009 IP
  12. @SHFAQ

    @SHFAQ Well-Known Member

    Messages:
    257
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #852
    Will anyone plz help me ?
     
    @SHFAQ, Jun 29, 2009 IP
  13. HighRankingSEO

    HighRankingSEO Active Member

    Messages:
    423
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    50
    #853
    How would you go about mod_rewriting OUT a directory? Is it possible?

    Can I rewrite this with a rule:
    mysite.com/SUPER/ROCKIN/COOL/AWESOME/whatever.html

    to this:

    mysite.com/COOL/AWESOME/whatever.html

    (REWRITE OUT THE SUPER AND ROCKIN WITHOUT REMOVING THE DIRECTORIES)

    I feel like this is possible, maybe not...I don't know. I would appreciate any help. Also, if this is possible, anyone have the general rules I would write/follow to make this happen.

    SOME ADDITIONAL INFO:
    ASSUME THAT "ROCKIN" AND "SUPER" ARE DIRECTORIES THAT CANNOT BE MOVED/DLETED/ETC....
     
    HighRankingSEO, Jul 11, 2009 IP
  14. Nintendo

    Nintendo ♬ King of da Wackos ♬

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

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /mb/
    RewriteRule ^(.*)$ http://www.new-domain.com/$1 [R=301,L]

    domain.com/.htaccess

    Options +FollowSymLinks +Indexes
    RewriteEngine on
    RewriteBase /
    RewriteRule ^COOL/AWESOME/([^.]+)\.html$ SUPER/ROCKIN/COOL/AWESOME/$1.html [L]
     
    Nintendo, Jul 11, 2009 IP
  15. HighRankingSEO

    HighRankingSEO Active Member

    Messages:
    423
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    50
    #855
    thta is great, thanks a lot...It's funny, I could not find one thing on the internet that had insturctions or the code written out to follow...I appreciate it, very nice.
     
    HighRankingSEO, Jul 11, 2009 IP
  16. Jack Zero

    Jack Zero Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #856
    If you want to redirect them all seperatly, you can do it like this in your old domain's .htaccess file:
    
    redirect 301 /abc.html http://www.newdomain.com/abc.html
    redirect 301 /def.html http://www.newdomain.com/def.html
    redirect 301 /ghi.html http://www.newdomain.com/ghi.html
    
    Code (markup):
     
    Jack Zero, Jul 12, 2009 IP
  17. Jack Zero

    Jack Zero Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #857
    First of all, thanks heaps for this tutorial I really appreciate it and it's already helped me lots. If anyone can help me out in writing a rule for this kind of url I'd be very gratefull.
     
    Jack Zero, Jul 12, 2009 IP
  18. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #858
    What do you want the URL to look like?
     
    Nintendo, Jul 13, 2009 IP
  19. Jack Zero

    Jack Zero Peon

    Messages:
    24
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #859
    Hello Nintendo :)
    Thank you very much for taking the time to help.

    Latest Articles: (/articles/latest-articles)
    http://www.mysite.com/searchresult.php?sort_id=3&sbtype=1&inname=-1,-1&exname=-1,-1&all=1

    Top Rated Articles: (/articles/top-articles)
    http://www.mysite.com/searchresult.php?sort_id=5&sbtype=1&inname=-1,-1&exname=-1,-1

    Looks like a war-zone in there doesn't it? :D
     
    Jack Zero, Jul 13, 2009 IP
  20. rohansyco

    rohansyco Member

    Messages:
    98
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #860
    Thanks a lot dude,,
     
    rohansyco, Jul 15, 2009 IP