WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Rewrite url from one install to another (8 posts)

  1. cjdjackson2hot
    Member
    Posted 2 years ago #

    Hi All

    I've got a tricky one that's quite hard to get (my) your head around so I'll try and keep it as clear and broken down as possible.

    I had my own website created in dreamweaver which was installed in my root folder on my ftp server. I then installed and setup wordpress in a directory in the root called 'blog'. I have been really happy with this up until recently.

    I have just decided to make my main website a wordpress website. I have now installed it all into the root directory and it is all working well. I have migrated my old posts etc into my new website all in one blog site.

    So I have redirected all of my old html pages to my new wordpress pages using the below 301 redirects in my .htaccess file. I now want to

    1) name a page blog (which is a category archive page of any posts in the category 'blog') -with the slug 'blog' which will result in http://www.mydomain.co.uk/blog/ when visited.

    2) bearing the above point in mind is it possible / I want to use a rewrite rule to redirect anybody that tries to visit my other blog which is accessible via http://www.mydomain.co.uk/blog/ (the same as the url with the category slug above) - to the post but on my new site..... example:

    old link to single post- http://www.mydomain.co.uk/blog/client-demo/

    this same single post is on my new website now and would be accessed via - http://www.mydomain.co.uk/client-demo/

    so basically a rule that removes the word blog from the url but keeps the rest of the url.

    To round up if I have a category archive page with the slug / name 'blog' is there still a way of writing a redirect / rewrite rule to re-direct any posts that are '/blog/exampletext (so anything that has any kind of text after the slash at the end of the word blog) so that when someone tries to visit my category archive page without being redirected to the url with the word 'blog' removed.

    Thank in advance, and if I can help clear it up please ask any questions.

    Chris

    P.S. here is my current htaccess file:

    RewriteEngine On
    #
    RewriteCond %{HTTP_HOST} !^www.mydomain.co.uk$ [NC]
    RewriteRule ^(.*)$ http://www.mydomain.co.uk/$1 [L,R=301]
    #
    RewriteRule ^view/([0-9]+).html$ http://www.mydomain.co.uk/photocart/index.php?do=photocart&viewGallery=$1 [L,R=301,NC]
    #
    RewriteRule ^view/([0-9]+)$ http://www.mydomain.co.uk/photocart/index.php?do=photocart&viewGallery=$1 [L,R=301,NC]
    #
    Redirect 301 /wedding-and-portrait-photographer/index.html http://www.mydomain.co.uk/
    
    Redirect 301 /wedding-and-portrait-photographer/contact.html http://www.mydomain.co.uk/contact/
    
    Redirect 301 /wedding-and-portrait-photographer/about.html http://www.mydomain.co.uk/about/
    
    Redirect 301 /wedding-and-portrait-photographer/portfolio.html http://www.mydomain.co.uk/wedding-photography-portfolio/
    
    Redirect 301 /wedding-and-portrait-photographer/faq.html http://www.mydomain.co.uk/about/what-our-clients-think/
    
    Redirect 301 /wedding-and-portrait-photographer/reviews.html http://www.mydomain.co.uk/contact/
    
    Redirect 301 /wedding-and-portrait-photographer/venues.html http://www.mydomain.co.uk/wedding-venues/
    
    Redirect 301 /wedding-and-portrait-photographer/wedding.html http://www.mydomain.co.uk/wedding-photography-portfolio/
    
    Redirect 301 /wedding-and-portrait-photographer/products.html http://www.mydomain.co.uk/albums/
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
  2. You can remove the /blog/ slug, though every time you re-save permalinks in the main site, it will come back.

    If you were to remove it and make a page, then you would not be able to, at the same time use an efficient .htaccess redirect, as you actually have a page, and any redirect would kill the archives.

    The thing is, if you have a subfolder install, then by default the URLs will be this anyway: http://www.mydomain.co.uk/blog/client-demo/

    So why not just leave it alone, set your URLs to %postname% and not have to mess with it?

  3. cjdjackson2hot
    Member
    Posted 2 years ago #

    Let's make it alot easier as I think you haven't understood the situation as it is.

    How can I make a rule that will basically rewrite any url typed in that has ANYTHING after the /blog/ part..... to change the url to just remove the blog part

    i.e.

    if user types in http://www.mydomain.co.uk/blog/demo to be re-written to http://www.mydomain.co.uk/demo

    so any text after the '/blog/' is copied and just added to http://www.mydomain.co.uk OR another way to look at it is so that it is simply removing the '/blog/' part but keeping the following text.

    Once we have a rule that does that I can then explain / ask if its possible to do the next part / just live with it.

    Thanks

    Chris

  4. RewriteRule ^blog/(.*)$ http://www.mydomain.co.uk/$1 [L,R=301]
  5. cjdjackson2hot
    Member
    Posted 2 years ago #

    Sorry to be a pain but it doesn't seem to be working

    the actual URL is

    http://www.chrisjacksonphoto.co.uk/blog/

    I have now deleted the directory 'blog' so now it just displays an error page....

    here is my .htaccess file as it stands - can you see anything that would be causing it not to redirect:

    RewriteEngine On
    #
    RewriteCond %{HTTP_HOST} !^www.chrisjacksonphoto.co.uk$ [NC]
    RewriteRule ^(.*)$ http://www.chrisjacksonphoto.co.uk/$1 [L,R=301]
    #
    RewriteRule ^view/([0-9]+).html$ http://www.chrisjacksonphoto.co.uk/photocart/index.php?do=photocart&viewGallery=$1 [L,R=301,NC]
    #
    RewriteRule ^view/([0-9]+)$ http://www.chrisjacksonphoto.co.uk/photocart/index.php?do=photocart&viewGallery=$1 [L,R=301,NC]
    #
    RewriteRule ^/blog/(.*)$ http://www.chrisjacksonphoto.co.uk/$1 [L,R=301]
    #
    Redirect 301 /wedding-and-portrait-photographer/index.html http://www.chrisjacksonphoto.co.uk/
    
    Redirect 301 /wedding-and-portrait-photographer/contact.html http://www.chrisjacksonphoto.co.uk/contact-chris-jackson-photo/
    
    Redirect 301 /wedding-and-portrait-photographer/about.html http://www.chrisjacksonphoto.co.uk/about/
    
    Redirect 301 /wedding-and-portrait-photographer/portfolio.html http://www.chrisjacksonphoto.co.uk/wedding-photography-portfolio/
    
    Redirect 301 /wedding-and-portrait-photographer/faq.html http://www.chrisjacksonphoto.co.uk/about/what-our-clients-think/
    
    Redirect 301 /wedding-and-portrait-photographer/reviews.html http://www.chrisjacksonphoto.co.uk/contact-chris-jackson-photo/
    
    Redirect 301 /wedding-and-portrait-photographer/venues.html http://www.chrisjacksonphoto.co.uk/wedding-venues/
    
    Redirect 301 /wedding-and-portrait-photographer/wedding.html http://www.chrisjacksonphoto.co.uk/wedding-photography-portfolio/
    
    Redirect 301 /wedding-and-portrait-photographer/products.html http://www.chrisjacksonphoto.co.uk/albums/
    
    Redirect 301 /wedding-and-portrait-photographer/venues/claydon-house-wedding-photographer.html http://www.chrisjacksonphoto.co.uk/wedding-venues/claydon-house-wedding-photographer-claydon-wedding-photographer-chris-jackson-photo/
    
    Redirect 301 /wedding-and-portrait-photographer/venues/eaves-hall-wedding-photographer.html http://www.chrisjacksonphoto.co.uk/wedding-venues/eaves-hall-wedding-photographer-clitheroe-wedding-photographer-chris-jackson-photo/
    
    Redirect 301 /wedding-and-portrait-photographer/venues/inn-at-whitewell-wedding-photographer.html http://www.chrisjacksonphoto.co.uk/wedding-venues/inn-at-whitewell-wedding-photographer-clitheroe-wedding-photographer-chris-jackson-photo/
    
    Redirect 301 /wedding-and-portrait-photographer/venues/langdale-chase-wedding-photographer.html http://www.chrisjacksonphoto.co.uk/wedding-venues/langdale-chase-wedding-photographer-lake-district-wedding-photographer-chris-jackson-photo/
    
    Redirect 301 /wedding-and-portrait-photographer/venues/norton-grange-wedding-photographer.html http://www.chrisjacksonphoto.co.uk/wedding-venues/norton-grange-wedding-photographer-rochdale-wedding-photographer-chris-jackson-photo/
    
    Redirect 301 /wedding-and-portrait-photographer/venues/rudding-park-wedding-photographer.html http://www.chrisjacksonphoto.co.uk/wedding-venues/rudding-park-wedding-photographer-harrogate-wedding-photographer-chris-jackson-photo/
    
    Redirect 301 /wedding-and-portrait-photographer/venues/sparth-house-wedding-photographer.html http://www.chrisjacksonphoto.co.uk/wedding-venues/sparth-house-hotel-wedding-photographer-lancashire-wedding-photographer-chris-jackson-photo/
    
    Redirect 301 /wedding-and-portrait-photographer/venues/the-place-hotel-wedding-photographer.html http://www.chrisjacksonphoto.co.uk/wedding-venues/the-place-hotel-wedding-photographer-manchester-wedding-photographer-chris-jackson-photo/
    
    Redirect 301 /wedding-and-portrait-photographer/venues/york-pavillion-wedding-photographer.html http://www.chrisjacksonphoto.co.uk/wedding-venues/york-pavilion-wedding-photographer-chris-jackson-photo/
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
  6. cjdjackson2hot
    Member
    Posted 2 years ago #

    scratch that....it seems to redirect it even if it doesn't always remove the actual blog part from the URL it does load the page it should on the new site.....asI've deleted the old blog directory now.

    Can I use the following rule to direct a request of specifically:

    http://www.chrisjacksonphoto.co.uk/blog/ to load http://www.chrisjacksonphoto.co.uk/wedding-photography-blog/

    or will this stop the rule you posted last from working correctly?

  7. Compare this:
    RewriteRule ^blog/(.*)$ http://www.mydomain.co.uk/$1 [L,R=301]

    With this:
    RewriteRule ^/blog/(.*)$ http://www.chrisjacksonphoto.co.uk/$1 [L,R=301]

    You put a / in front of blog.

  8. cjdjackson2hot
    Member
    Posted 2 years ago #

    I did as it wasn't working - as that is the directory it was in....anyway it's working now.

    I also added in the following rules to combat anyone trying to visit ..../blog or ..../blog/

    Redirect 301 /blog/ http://www.chrisjacksonphoto.co.uk/wedding-photography-blog/
    #
    Redirect 301 /blog http://www.chrisjacksonphoto.co.uk/wedding-photography-blog/

    this all seems to be working correctly now so thank you very much for your help :)

Topic Closed

This topic has been closed to new replies.

About this Topic