Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    301 redirect htaccess code?

    Hi Guys,
    I'm taking an old website I have and 301 redirecting it to a brand new site.

    The problem is that it has about 20 pages ending in www. oldsite/public_html/oldpage.html
    and I want them all to go to my new website which doesnt have html extensions.
    www. NEWsite/NEWPAGE


    what is the code for redirecting .html to regular webpages?

    I tried this...

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://www.NEW WEBSITE.com/$1 [R=301,L]

    But it only works for the homepage.

    No matter what I try, the other pages show up as www .NEW WEBSITE/public_html/oldpagename.html/
    resulting in a 404 page (wordpress then says "Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post." with a search box.)

    Can anyone help?
    thanks
    Last edited by flegg; 01-17-2012 at 01:03 AM.

  • #2
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    can anyone help me with this?
    in a coding forum, no one has an answer?
    thanks

  • #3
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Your match includes everything. Pull the extension out of the pattern to capture and use that instead.
    Why do you have no extensions on your pages?

  • #4
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    Your match includes everything. Pull the extension out of the pattern to capture and use that instead.
    Why do you have no extensions on your pages?
    thanks Fou-Lu
    I am moving an html site to wordpress, that's why I dont need .html anymore.

    can you please explain "Your match includes everything. Pull the extension out of the pattern to capture and use that instead"?

    what would the code be for example,
    sending www. oldsite/public_html/oldpage.html
    to www. newsite.com/newpage

    thanks

  • #5
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    can anyone help me with this please?
    thanks

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    I still don't understand why you are dropping the extension. I would presume wordpress is still using .php pages regardless of what the .htaccess is ruling.
    For your match, you need to specify to remove the .html from it. Use ^(.*)\.html$ for the pattern. This will redirect from x.html to newsite/x with no extension.

  • #7
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Fou-Lu View Post
    I still don't understand why you are dropping the extension. I would presume wordpress is still using .php pages regardless of what the .htaccess is ruling.
    For your match, you need to specify to remove the .html from it. Use ^(.*)\.html$ for the pattern. This will redirect from x.html to newsite/x with no extension.
    I am dropping the extension because the old pages no longer apply. I replaced them with better subjects in general.

    thanks so where does \.html$ go in the below code?

    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule (.*) http://www.NEW WEBSITE.com/$1 [R=301,L]

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    It replaces your match of (.*).

  • #9
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Options +FollowSymLinks
    RewriteEngine on
    RewriteRule ^(.*)/OLDPAGE.html$ http://www.NEW WEBSITE.com/$1 [R=301,L]

    still not working for anything but the home page.
    is something wrong with my code?
    thanks

  • #10
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    Yeah, you didn't replace the pattern with my suggestion of ^(.*)\.html$.

    Edit:
    Oh you have an explicit name there. Are you wanting all .html pages or just that one? Also, its not .html, it should be \.html, although it won't make too much of a difference in this example since . does match any character specified by ..
    Edit:
    BTW, the pattern you have here would attempt to match a subdirectory of unknown name containing oldpage.html. So a match to mysubdir/oldpage.html would redirect to /mysubdir.

    Last edited by Fou-Lu; 01-23-2012 at 06:44 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •