• WPChina

    (@wordpresschina)


    Yikes, I’m still having problems.

    I just changed a blog over to wordpress. The old RSS feed was found at http://www.domain.com/news.rss and I want to change it to the wordpress feed at http://www.domain.com/feed/

    I tried doing this, but it did not work:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    RewriteRule ^feed$ news.rss [L]
    </IfModule>

    Any ideas what I’m doing wrong?

    Tks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter WPChina

    (@wordpresschina)

    Sorry, but does anyone have any ideas what I’m doing wrong?

    I’m sure I am very close to fixing this and I just made a small mistake in my htaccess, but I can’t spot the error. Is the problem that I am only trying to change a redirect on one file, and not an entire directory? Can I not redirect only one file?

    Tks!

    Let me preface this by saying I stink at rewrite rules and that a more specialized forum might be a better place to ask your question.

    That being said, is yours backwards?

    Instead of

    RewriteRule ^feed$ news.rss [L]

    try

    RewriteRule ^news.rss /feed/ [R=301,L]

    Maybe?

    Thread Starter WPChina

    (@wordpresschina)

    Thank you for your tip HandySolo. I tried both
    RewriteRule ^news.rss$ /feed/ [R=301,L]
    and
    RewriteRule ^news.rss /feed/ [R=301,L]

    but neither worked–both gave me 404 Page Not Found errors. This seems like such an easy fix, so I’m wondering if maybe the problem is a setting on my server? Custom permalinks work fine, though, so I am bewildered.

    I found some links on this forum to specialized BBSs off-site, and I implemented some of those suggestions, but nothing seems to work. This is why I’ve returned to the WP community for help… 🙂

    Hey I just spent a lot of time trying to play with the htaccess file for this reason:

    I had a lot of old html files and i wanted to route it to the new page locations.

    I found that it was rather simple.

    Example: If I had a page at http://www.domain.com/blog/hello.html and the new location was http://www.domain.com/wordpress/blog/bingo.html it was as simple as adding this:

    Redirect /blog/hello.html http://www.domain.com/wordpress/blog/bingo.html

    Maybe that’ll help… worked for me.

    Thread Starter WPChina

    (@wordpresschina)

    Wow: very simple and works very very well! Thank you Nedyken!

    Lol, here we are trying to get all fancy with our regexp skills… Nedyken cuts straight to the chase.

    Good save!

    Thread Starter WPChina

    (@wordpresschina)

    Yup!

    After I got your tip I found lots of webpages with the same tips, so I also added “301” in that line. It is optional, but I think it’s best to have. So this is what I have, and works very well:

    Redirect 301 /news.rss http://www.domain.com/feed/

    Sometimes finding the correct answer on the Internet is difficult and all you need is a small nudge in the right direction to find everything you need 🙂

    Thread Starter WPChina

    (@wordpresschina)

    I have one more follow-up. I am changing the domain name of my site from abc.com to xyz.com. All the permalinks will have the same structure, the database is identical, and I will change the DNS of abc.com to point to xyz.com, so how can I make my old links and permalinks at

    abc.com/%year%/%monthnum%/%day%/%post_id%/%postname%/

    point instead to

    xyz.com/%year%/%monthnum%/%day%/%post_id%/%postname%/

    Thanks for your tips!

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Add this before any other rules in your root’s .htaccess file:

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} ^abc\.com$ [NC]
    RewriteRule ^(.*)$ http://xyz.com/$1 [R=301,L]
    </IfModule>

    Alternatively, this one will redirect anything that is not “xyz.com” to “xyz.com”. So in case you decide to point def.com or ghi.com to it as well, this will handle it all.

    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{HTTP_HOST} !^xyz\.com$ [NC]
    RewriteRule ^(.*)$ http://xyz.com/$1 [R=301,L]
    </IfModule>
    Thread Starter WPChina

    (@wordpresschina)

    That works!

    One more request for help. I also slightly changed my permalink structure on another blog from this:

    /%year%/%monthnum%/%day%/%postname%/

    to this:

    /%year%/%monthnum%/%day%/%post_id%-%postname%/

    How can I change my htaccess to reflect this change?

    OTTO

    Would this same code work for subdomains as well?
    The way I am understanding the rewrite up there is that anything pointing at xyz.com will go to xyz.com no matter what is pointing to that domain? With xyz.com being your Top Level Domain yoursitename.com?

    And this same redirect will take care of all www pointing to //yoursitename.com?

    Sorry probably thinking too much but thought I’d ask just to make sure I was understanding correctly.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Help with .htaccess and RewriteRule’ is closed to new replies.