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. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #141
    I always try to keep spaces out. Old browsers can cause a 404 error with those URLs, and new browsers change it to the space character, something like %20 . What kind of script is it?
     
    Nintendo, Nov 18, 2005 IP
  2. soul-healer

    soul-healer Peon

    Messages:
    1,459
    Likes Received:
    145
    Best Answers:
    0
    Trophy Points:
    0
    #142
    I have written a script myself for directory listing. I will PM you the url.
     
    soul-healer, Nov 19, 2005 IP
  3. Imran

    Imran Notable Member

    Messages:
    2,340
    Likes Received:
    190
    Best Answers:
    0
    Trophy Points:
    230
    #143
    Just want to add some thing to this FAQ,..
    Redirecting the pages ending with a certain extension to another one,..
    for example you have pages ending with .html and want to redirect all request's to shtml pages with same url but the extension as shtml..
    You can use this code!

    RedirectMatch (.*)\html$ (.*)\shtml$
    It works nice!
     
    Imran, Nov 24, 2005 IP
  4. Imran

    Imran Notable Member

    Messages:
    2,340
    Likes Received:
    190
    Best Answers:
    0
    Trophy Points:
    230
    #144
    hi I need few Urls, to be mod,..
    Can you suggest Short urls for these urls,...
    index.php?page=shownews&newsid=1
    index.php?page=allnews
    index.php?page=stories
    index.php?page=login
    index.php?page=privacy
    index.php?page=terms_of_use
    index.php?page=faq
    I will be glad, If the urls look like /shownews1.html or shownews2.html
    Thanks In advance:)
     
    Imran, Nov 26, 2005 IP
  5. webdesignlab

    webdesignlab Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #145
    Hi,

    I have a seo question about 301 redirect. I have two domains www.domain.com & www.domain2.com.

    I would like www.domain2.com to be redirected to www.domian.com/spanish_version.

    I already have search engine listings for www.domain.com but not the other. The Spanish folder exists too.

    www.domian2.com is keyword friendly.

    Firstly, can I use a 301 for this and what syntax do I use in my .htaccess?

    Secondly, will this be seen as spamming or any other negative search engine problem?

    Thanks for any help with this

    Web.
     
    webdesignlab, Nov 26, 2005 IP
  6. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #146
    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)/([^.]+)\.html$ index.php?page=$1&newsid=$2 [L]
    RewriteRule ^([^.]+)\.html$ index.php?page=$1 [L]

    Options +Indexes
    Options +FollowSymlinks
    RewriteEngine on
    RewriteBase /
    RewriteRule ^([^.]+)$ http://www.domian.com/spanish_version [R=301,L]
     
    Nintendo, Nov 26, 2005 IP
  7. Imran

    Imran Notable Member

    Messages:
    2,340
    Likes Received:
    190
    Best Answers:
    0
    Trophy Points:
    230
    #147
    Thanks for the Help, It really helped me..
    I had a rough Idea and now I can implement it!
    Im getting for one page 404 I will let you know about it first let me do the above given code thanks!
     
    Imran, Nov 27, 2005 IP
  8. DarrenC

    DarrenC Peon

    Messages:
    3,386
    Likes Received:
    154
    Best Answers:
    0
    Trophy Points:
    0
    #148
    Great article Nintendo!

    I can do the 301 direct on an individual page, but when it comes down to doing it on all of the domain I'm having problems.

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

    What should go in 'whatever' the index.html or .php or the domain www.mydomain.com?

    Ta
    Darren
     
    DarrenC, Dec 4, 2005 IP
  9. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #149
    That example is for

    domain.com/whatever/(.*) moving to new-site.com/$1/

    (.*) and $1 being all files that have the same name at the old and new location.

    Old URL directory/files go first, then the new one where it shows the full URL.

    for a complete domain...

    RewriteRule ^(.*)$ http://www.my-site.com/$1 [R=301,L]
     
    Nintendo, Dec 5, 2005 IP
    DarrenC likes this.
  10. keral82

    keral82 Banned

    Messages:
    781
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    0
    #150
    Thanks nintendo. I read the guidelines you have posted here and it worked for me. Thanks for sharing this.
     
    keral82, Dec 5, 2005 IP
  11. DarrenC

    DarrenC Peon

    Messages:
    3,386
    Likes Received:
    154
    Best Answers:
    0
    Trophy Points:
    0
    #151
    Nintendo, that worked perfectly for the test domains I've been playing with.

    I have a few questions if that's okay;

    1. Will it pass through the PR for www.old-domain.com to the www.new-domain.com?

    2. Is it best to ask your link partners to change the domain or will the search engines do that?

    3. In your experience in doing a 301 direct, have you lost rankings, and if so how long has this lasted. For example if the domain is new, would it go into the sandbox?

    I've made a big decision into go and change the domain of my main site, so if you have any other advice it would be appreciated.

    Darren
     
    DarrenC, Dec 5, 2005 IP
  12. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #152
    I've done it once and the PR was moved. I'm not sure about the other two. Make a thread in the Google board.
     
    Nintendo, Dec 5, 2005 IP
  13. DarrenC

    DarrenC Peon

    Messages:
    3,386
    Likes Received:
    154
    Best Answers:
    0
    Trophy Points:
    0
    #153
    Okay will do Nintendo :)

    Just one thing I have noticed testing this 301 direct out. I have a domain www.old-domain.com and have asked it to point to www.new-domain.com but if I type in www.old-domain.com/forum it doesnt point to www.new-domain.com - it brings up an error 404 on the old domain.

    So I'm a little baffled now lol

    If I wanted to point www.old-domain.com/forum to the new domain would I need a new line in the .htaccess file? The site I am looking to do the domain change for has a couple of hundred PHP and HTML pages.
     
    DarrenC, Dec 5, 2005 IP
  14. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #154
    RewriteRule ^(.*)$ http://www.my-site.com/$1 [R=301,L]

    Should get the whole domain.

    Try

    RewriteRule ^forum/(.*)$ http://www.my-site.com/forum/$1 [R=301,L]

    and/or

    RewriteRule ^forum/$ http://www.my-site.com/forum/ [R=301,L]

    in .htaccess in the main directory.

    if those don't work, post your current .htaccess code with the domain name changed.
     
    Nintendo, Dec 5, 2005 IP
  15. DarrenC

    DarrenC Peon

    Messages:
    3,386
    Likes Received:
    154
    Best Answers:
    0
    Trophy Points:
    0
    #155
    Okay, that makes sense.

    So do I have to set up the same file structure on the new domain as in the old domain, i.e. have a /forum/ folder. Sorry, if it sounds a dumbarse question lol
     
    DarrenC, Dec 5, 2005 IP
  16. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #156
    It can be different on the new domain.

    RewriteRule ^forum/(.*)$ http://www.my-site.com/messageboards/$1 [R=301,L]

    for example. And having a / at the end of both is probably required if you link to it with the / . First part shows the directory info for the current URL, then the new domain and directory info which can be anything.
     
    Nintendo, Dec 5, 2005 IP
  17. DarrenC

    DarrenC Peon

    Messages:
    3,386
    Likes Received:
    154
    Best Answers:
    0
    Trophy Points:
    0
    #157
    Thanks Nintendo. That worked great.

    Are there a limit to how many RewriteRule's you can have in an .htaccess file?
     
    DarrenC, Dec 5, 2005 IP
  18. Nintendo

    Nintendo ♬ King of da Wackos ♬

    Messages:
    12,890
    Likes Received:
    1,064
    Best Answers:
    0
    Trophy Points:
    430
    #158
    I don't think so!! I got 56 lines on my Amazon sites.
     
    Nintendo, Dec 5, 2005 IP
  19. Dekker

    Dekker Peon

    Messages:
    4,185
    Likes Received:
    287
    Best Answers:
    0
    Trophy Points:
    0
    #159
    (nintendo is actually the creater of the .htaccess module and will soon use it to control the internet)

    do not be fooled!!!! send money to SVZ to be saved.
     
    Dekker, Dec 8, 2005 IP
  20. DarrenC

    DarrenC Peon

    Messages:
    3,386
    Likes Received:
    154
    Best Answers:
    0
    Trophy Points:
    0
    #160
    Argh

    I want to mod rewrite /travel/travel-services.php?travel_service=Insurance
    to be /travel-shop/Insurance.html

    Any ideas mod rewrite wacko expert? :D
     
    DarrenC, Dec 17, 2005 IP