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.

301 Redirect http:// to http://www. help needed

Discussion in 'Apache' started by syted, Sep 24, 2007.

Thread Status:
Not open for further replies.
  1. #1
    Since installing a wordpress blog on my site I have this problem. I want to redirect all pages like http://linklister.co.uk/blog/ to http://www.linklister.co.uk/blog/. I have tried a few different 301 redirects but none of them have worked. If necessary I will pay somebody to sort this out for me. Here's the htaccess code as it is with no redirect.
    #################################################
    ## PHP Link Directory - Apache Server Settings ##
    #################################################
    
    # Prevent .htaccess and .htpasswd files from being viewed by web clients
    <Files "^\.ht">
        Order allow,deny
        Deny from all
    </Files>
    
    # Protect files
    <Files ~ "^(.*)\.(inc|inc\.php|tpl|sql)$">
      Order deny,allow
      Deny from all
    </Files>
    
    # Protect directories
    <Files ~ "^(backup|files|images|include|lang|libs(/.+)?|temp(/.+)?|templates(/.+)?|javascripts(/.+)?)$">
      Order deny,allow
      Deny from all
    </Files>
    
    # Disable directory browsing
    Options -Indexes
    
    # Follow symbolic links in this directory
    Options +FollowSymLinks
    
    # Override PHP settings that cannot be changed at runtime
    # (If your server supports PHP settings via htaccess you can comment following two lines off)
    # php_value register_globals   0
    # php_value session.auto_start 0
    
    # Customized error messages
    # ( If you are running in a subfolder please add it, example: "directory/index.php?httpstatus=404" )
    ErrorDocument 404 index.php?httpstatus=404
    
    # Set the default handler
    DirectoryIndex index.php
    
    # URL rewrite rules
    <IfModule mod_rewrite.c>
       RewriteEngine On
       
       	## A-Z Links Rewrite##
       	RewriteCond %{REQUEST_FILENAME} !-f
       	RewriteCond %{REQUEST_FILENAME} !-d
       	RewriteCond %{REQUEST_FILENAME} !-l
    	RewriteRule (.*)alpha-(.*)/ index.php?letter=$2 [QSA,NC]
    	
    	## Pagerank Stats Rewrite##
    	RewriteCond %{REQUEST_FILENAME} !-f
    	RewriteCond %{REQUEST_FILENAME} !-d
    	RewriteCond %{REQUEST_FILENAME} !-l
    	RewriteRule (.*)livepagerank-(.*)/ index.php?pr=$2 [QSA,NC]
    
       ## Details Link Page Rewrite##
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-l
       RewriteRule (.*)detail/link-(.*).htm[l]?$ detail.php [QSA,NC]
    
       ## Pagination Rewrite
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-l
       RewriteRule (.*)page-(\d+)\.htm[l]?(.*)$  $1/?p=$2 [PT,NC]
    
       ## Category redirect
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteCond %{REQUEST_FILENAME} !-l
       RewriteRule ^(.*)$ index.php [QSA,L]
       
    
    </IfModule>
    Code (markup):
    TIA, Steve
     
    syted, Sep 24, 2007 IP
  2. powerspike

    powerspike Peon

    Messages:
    312
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i have done the same thing recently, i copyed the blog from it's home on /blog to a different site, this will also redirect all the arictles to the same url on the new host, just modify for yourself
    (these need to go at top of the file of the old location)


    ### BLOG REDIRECT
    RewriteRule ^blog([/]?)$ http://www.sitearmoryblog.com/ [L,R=301]
    RewriteRule ^blog/([0-9a-zA-Z/\_\-]+)$ http://www.sitearmoryblog.com/$1 [L,R=301]
     
    powerspike, Sep 24, 2007 IP
    syted likes this.
  3. syted

    syted Notable Member

    Messages:
    2,086
    Likes Received:
    319
    Best Answers:
    0
    Trophy Points:
    290
    #3
    Thanks but couldn't get it to work :confused:
     
    syted, Sep 27, 2007 IP
  4. cyanide

    cyanide Peon

    Messages:
    483
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #4
    IN the htaccess of your root, try
     
    cyanide, Sep 27, 2007 IP
    syted likes this.
  5. syted

    syted Notable Member

    Messages:
    2,086
    Likes Received:
    319
    Best Answers:
    0
    Trophy Points:
    290
    #5
    Thanks cyanide that has worked for the main site, problem now is when I navigate to the blog the links just lead back to the main site. I think I need to change the htaccess in the blog, this is the code:
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /blog/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /blog/index.php [L]
    </IfModule>
    
    # END WordPress
    Code (markup):
     
    syted, Sep 30, 2007 IP
  6. cyanide

    cyanide Peon

    Messages:
    483
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Really? that should've worked.. i think

    unless the htaccess for wordpress is mucking it up...
     
    cyanide, Oct 2, 2007 IP
  7. jmort732

    jmort732 Peon

    Messages:
    543
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Forgive me if this has been stated and tried. But I didn't see it in your .htaccess file.

    In your root .htaccess file at the top. Put

    Best of luck.
     
    jmort732, Oct 6, 2007 IP
    syted likes this.
  8. SilkySmooth

    SilkySmooth Well-Known Member

    Messages:
    1,583
    Likes Received:
    269
    Best Answers:
    0
    Trophy Points:
    180
    #8
    syted, PM me your FTP details and I will take a look for you.
     
    SilkySmooth, Oct 6, 2007 IP
    syted likes this.
  9. SasaVtec

    SasaVtec Notable Member

    Messages:
    1,588
    Likes Received:
    150
    Best Answers:
    0
    Trophy Points:
    275
    #9
    That has worked fine for me before and still does phpld and wordpress sites ex: http://directorymix.com and http://directorymix.com/blog
     
    SasaVtec, Oct 6, 2007 IP
    syted likes this.
  10. syted

    syted Notable Member

    Messages:
    2,086
    Likes Received:
    319
    Best Answers:
    0
    Trophy Points:
    290
    #10
    Thanks everybody for your helpful replies. Silky Smooth sorted it out for me in the end.
     
    syted, Oct 8, 2007 IP
  11. SilkySmooth

    SilkySmooth Well-Known Member

    Messages:
    1,583
    Likes Received:
    269
    Best Answers:
    0
    Trophy Points:
    180
    #11
    For those who were interested in the fix, I removed the wordpress .htaccess and placed the following into the root .htaccess:

    
       # Custom: Ensure www is used
       RewriteCond %{HTTP_HOST} ^linklister.co.uk [NC]
       RewriteRule ^(.*)$ http://www.linklister.co.uk/$1 [L,R=301]
       
       # Custom: Blog
       RewriteCond %{REQUEST_FILENAME} !-f
       RewriteCond %{REQUEST_FILENAME} !-d
       RewriteRule ^blog/(.*)$ /blog/index.php [L]
    
    Code (markup):
    Pretty much what people had suggested.
     
    SilkySmooth, Oct 8, 2007 IP
Thread Status:
Not open for further replies.