FAQ: mod_rewrite, 301 redirects, and optimizing Apache.

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

  1. scylla

    scylla Notable Member

    Messages:
    1,025
    Likes Received:
    33
    Best Answers:
    1
    Trophy Points:
    225
    #361
    My question is. I'm hosted at tetrahost.net. I want all of the pages to say this:
    gamers.puck3d.net
    instead of:
    gamers.tetrahost.net

    any suggestions on how to do this with a .htaccess file? gamers.puck3d.net is an add-on domain. And also I would like this to be applied to every page in every subdirectory.
     
    scylla, Jul 27, 2006 IP
  2. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #362
    At gamers.tetrahost.net/.htaccess

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)$ http://gamers.puck3d.net/$1/ [R=301,L]

    or try

    RewriteRule ^(.*)$ http://gamers.puck3d.net/$1/ [R=301,L]

    if some stuff doesn't redirect right.

    This would redirect everything from tetrahost.net to the other host.
     
    Nintendo, Jul 27, 2006 IP
  3. Not Registered

    Not Registered Well-Known Member

    Messages:
    685
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    120
    #363
    Greetings!

    We changed our old site from .asp to .php, using Joomla.
    After we got 'page not found' on Google, we implemented the 301 redirect.

    However, for technical constrains, we are still using IIS server.
    The result is that we don't see the images on our new site.

    Is there any solution? Cheers. ;)
     
    Not Registered, Jul 27, 2006 IP
  4. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #364
    Nintendo, Jul 27, 2006 IP
  5. Not Registered

    Not Registered Well-Known Member

    Messages:
    685
    Likes Received:
    58
    Best Answers:
    0
    Trophy Points:
    120
    #365
    Thank you very much!!
     
    Not Registered, Jul 27, 2006 IP
  6. scylla

    scylla Notable Member

    Messages:
    1,025
    Likes Received:
    33
    Best Answers:
    1
    Trophy Points:
    225
    #366
    neiter of those works:
    http://www.gamers.tetrahost.net/new.shtml

    there is no other host. I got gamers.puck3d.net from http://freedns.afraid.org/
    -------------------------------------------------------------------------------------------------------
    this is what gamers.tetrahost.net is running on:
    Operating System Linux
    Apache version 1.3.36 (Unix)
    Kernel version 2.4.21-40.EL
     
    scylla, Jul 27, 2006 IP
  7. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #367
    Do a .htaccess test

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^wacko\.shtml$ index.shtml [L]

    if it's index.shtml for the index and see if domain.com/wacko.shtml works. If that doesn't, try it with out the first two lines. If that doesn't, you don't have .htaccess support.

    Both of the URLs do have the content.

    http://gamers.puck3d.net/nintendo/nes/
    http://gamers.tetrahost.net/nintendo/nes/
     
    Nintendo, Jul 27, 2006 IP
  8. scylla

    scylla Notable Member

    Messages:
    1,025
    Likes Received:
    33
    Best Answers:
    1
    Trophy Points:
    225
    #368
    scylla, Jul 27, 2006 IP
  9. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #369
    Nintendo, Jul 27, 2006 IP
  10. scylla

    scylla Notable Member

    Messages:
    1,025
    Likes Received:
    33
    Best Answers:
    1
    Trophy Points:
    225
    #370
    scylla, Jul 27, 2006 IP
  11. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #371
    Not sure if it'll help. Since you got files that don't end in / and got directories...

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^(.*)/(.*)/(.*)\.php$ http://gamers.puck3d.net/$1/$2/$3.php [R=301,L]
    RewriteRule ^(.*)/(.*)\.php$ http://gamers.puck3d.net/$1/$2.php [R=301,L]
    RewriteRule ^(.*)$ http://gamers.puck3d.net/$1 [R=301,L]
     
    Nintendo, Jul 27, 2006 IP
  12. scylla

    scylla Notable Member

    Messages:
    1,025
    Likes Received:
    33
    Best Answers:
    1
    Trophy Points:
    225
    #372
    gah!!! that doesnt work either, just makes the pages freeze instead of finishing loading!
     
    scylla, Jul 28, 2006 IP
  13. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #373
    Make a post at
    webmasterworld.com/apache/
    The Apache King there knows more than me!!!! :D
     
    Nintendo, Jul 28, 2006 IP
  14. iqra_psh

    iqra_psh Active Member

    Messages:
    992
    Likes Received:
    113
    Best Answers:
    0
    Trophy Points:
    85
    #374
    365 days old,
    Happy Birthday to Your thread Nintendo. :)
    Best of Luck and Thanks for very good info and Help Provided to all of us.
     
    iqra_psh, Jul 30, 2006 IP
  15. axemedia

    axemedia Guest

    Messages:
    1,070
    Likes Received:
    79
    Best Answers:
    0
    Trophy Points:
    0
    #375
    I have domain.com/index.php?page=filename structure

    And am using RewriteRule ^(.*)\.html$ index.php?page=$1 [L]

    to get domain.com/filename.html

    This works for most my pages.

    I have some pages that I want in folders.

    I have filename1, filename2, filename3, filename4......
    that I want to be shown as

    domain/filename1/index.html (where index.html is filename1.html)
    domain/filename1/filename2.html
    domain/filename1/filename3.html
    domain/filename1/filename4.html

    What is the best way to do this?

    I could just use:
    domain/filename1.html (notice=> no folder here)
    or
    domain/filename1/filename1.html (double dose of keyword jam:( ? )

    domain/filename1/filename2.html
    domain/filename1/filename3.html

    and create folder name with RewriteRule ^filename1/(.*)\.html$ index.php?page=$1 [L]


    But that may mean that the leading page for that folder, and its contents, is not in the folder (if I use domain.com/filename1.html). Does that matter, SEO wise. I think it does, a bit. Plus having it all under the folder looks better in URL's

    Or i got some url keyword spamming if i use filename1/filename1.htm

    Or I just create a different name for folder and filename1. (as in, foldername/filename1.html) Hit 2 realated, but different, key phrases.:)

    My one problem with this is:
    My on site hard links will point to domain.com/filename1/filename2.html, but you could type in any page with that folder in url and get a valid page.

    example domain.com/filename1/filename13.htm (but i don't want 13 in that folder)

    Does this matter since SE's will see no links to these "potential"? Or should I 301 them back to index.php, or not bother. Who's going to be typing in multiple folder/filename combos for the hell of it? (besides me)


    What would a wacko do?
     
    axemedia, Aug 4, 2006 IP
  16. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #376
    Only link to da URLs you want the search engines to see. Now if there already indexed....
     
    Nintendo, Aug 4, 2006 IP
  17. Zapita

    Zapita Active Member

    Messages:
    220
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    88
    #377
    Hi, i'm trying to use:

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

    that doesn't do anything but sends me to the 404 error page of the original site, and if i use

    RedirectMatch permanent ^/foldername$ http://www.domain.com

    that makes the redirection fine.. but i want to pass the PR, what could be wrong and what can i do?
     
    Zapita, Aug 4, 2006 IP
  18. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #378
    Not sure if it'll do it, take out the / at the very end.

    RewriteRule ^foldername/(.*)$ http://www.domain.com/$1 [R=301,L]

    or

    RewriteRule ^foldername/(.*)$ http://www.domain.com/ [R=301,L]

    if you want them all to the URL in the RedirectMatch permanent code there.
     
    Nintendo, Aug 4, 2006 IP
  19. Zapita

    Zapita Active Member

    Messages:
    220
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    88
    #379
    i tried and it didn't work :/

    what's the difference doing it with
    [I]redirect 301 /directory http://www.domain.com[/I]
    Code (markup):
    i tried that and it worked, just want to be sure that will help to pass the PR
     
    Zapita, Aug 4, 2006 IP
  20. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #380
    I think that'll work, 301 wise. I've never tried that version of redirect.
     
    Nintendo, Aug 5, 2006 IP