WordPress.org

Forums

[resolved] Redirect from WordPress directory (10 posts)

  1. jeremycherfas
    Member
    Posted 7 years ago #

    I used to have my blog at jeremycherfas.net/wp working fine there and at wp.jeremycherfas.net. Then, after an upgrade, it stopped working, but I didn't notice for an age. So I cannot remember exactly how I had set it up to ensure that both mydomain/wp and wp.mydomain went to the blog page.

    I tried a few options but none seemed to work.

    Then I followed the instructions at http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory and the blog now works fine at jeremycherfas.net, which is OK. But if anyone goes to jeremycherfas.net/wp they get a Not Found. This is because there is still an index.php at jeremycherfas.net/wp but if I simply delete that then people get You do not have permission.

    What's the best way to get jeremycherfas.net/wp to point to jeremycherfas.net? I guess I could make an index.html page that contains just a redirect. But that will not work if someone comes looking for a specific post at jeremycherfas.net/wp/specificpost

    I don't really know enough about htaccess to craft my own redirect under wp

    Can someone help with the code I need to ensure that all pages that begin jeremycherfas.net/wp/ are redirected to jeremycherfas.net ?

    Thanks

  2. Well, we'd need more information to understand your setup more (contents of htaccess files, how you did have it working, etc), but my general advice would be to stop messing about and pick one or the other. Having multiple URLs is not good for search engines (they see duplicated content and ding you down for it), and it's not good for your users.

    Pick a single location. Get WordPress working there. Leave it there. Don't try to get all clever on it with several different URLs and such.

  3. jeremycherfas
    Member
    Posted 7 years ago #

    To be honest, I don't know how I had it working. That was my problem; I couldn't remember how I had set it up.

    I'm happy to go with my current set-up henceforth. But there are links out there that refer to the two different URLs.

    How would you recommend me to deal with the file not found errors when people go to the URL?

    Would it make sense to have a page there explaining what had happened and a redirect after, say, 10 seconds to the main blog page?

    Thanks

  4. How would you recommend me to deal with the file not found errors when people go to the URL?

    If the URLs are pretty close to compatible, then simply redirect from one to the other using .htaccess files. Something like this:

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

  5. jeremycherfas
    Member
    Posted 7 years ago #

    Thanks. I'll try that. Just one further question, if you don't mind. Does that go in the htaccess of the /wp directory? I assume it does, but I want to be sure in case I mess up.

  6. Yes, you're correct about the location. This assumes that nothing else is in that directory, of course.

  7. jeremycherfas
    Member
    Posted 7 years ago #

    I've tried as you suggested, and adding that line to the htaccess file, but it didn't work. Can you help some more?

    Here's the situation:

    My blog is at jeremycherfas.net/

    WordPress is installed at jeremycherfas.net/wp/

    At public_html (which I believe is effectively at jeremycherfas.net) I have this htaccess:

    SecFilterEngine On
    SecFilterSelective "POST_PAYLOAD" "6x.to" "allow,nolog"
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress

    At jeremycherfas.net/wp/ I have an almost identical htaccess:

    SecFilterEngine On
    SecFilterSelective "POST_PAYLOAD" "6x.to" "allow,nolog"
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /wp/
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    # RewriteRule ^/wp/(.*) http://www.jeremycherfas.net/$1 [R=301,L]
    RewriteRule . /wp/index.php [L]
    </IfModule>
    
    # END WordPress

    You can see that I commented out the rewriterule you supplied, because it did not seem to work.

    As I understand it, the $1 reference in the rewriterule says add whatever came after the /wp/ to http://www.jeremycherfas.net/ which is exactly what I want it to do. And the [L] means it is the last rule so the next one is skipped anyway.

    I tried the same rule in the higher directory and it did not work there either.

    All help very gratefully received; I would really like to get this working!

    Thanks again.

  8. Ah. Okay, no I assumed that the wp directory was empty. If that's the actual location, then there's nothing you can do about it. If you have WordPress in wp then that's where it is. You actually have to move it somewhere else if you want it to be somewhere else.

    What you've explained so far is basically a horrific mess. Given that situation, I'd backup the database, scrap WordPress, reinstall from scratch, and restore the database to get everything back. But that's just me.

    Decide what you want to be the case as far as your URLs are concerned and explain what actually *is* the case currently and then you can determine how to get there from here.

    The fact that you have two different .htaccess files is also a problem. One of these is unnecessary, the other is incorrect. This is why I call it "a mess".

  9. jeremycherfas
    Member
    Posted 7 years ago #

    I agree that it is a mess, though maybe not horrific. And that is why I want to clean it up.

    Thinking more about it, this could be a hosting issue. My host has virtual domains, whereby mydomain.com/blog/ is the same as blog.mydomain.com

    That's certainly what I used to have, operationally, and that is where I want to be again.

    So I think I will put everything back as it was and take this up with the hosting company. You may think this is what I should have done in the first place.

    Thanks for all your help.

  10. jeremycherfas
    Member
    Posted 7 years ago #

    I now suspect it was hosting. I went back in, cleaned up, restored the status quo, and things seem to be operational.

    Thanks for the help.

Topic Closed

This topic has been closed to new replies.

About this Topic