Jump to content
nirenjan

Directory Level Redirects

Recommended Posts

Hi,

 

I've just moved to TCH from another host and have installed WordPress. I want to permanently redirect requests to /Blog/feed.asp to http://www.nirenjan.com/feed/, while all other files/folders under /Blog/ are to be redirected to the root folder (http://www.nirenjan.com/). Also the request matching needs to be case insensitive.

 

How do I set up this rule in either CPanel or .htaccess? I tried with CPanel to redirect both /blog/ and /Blog/ to the main page, but it's accepting only one and if I try to enter the other, it's giving me a 404 error.

Share this post


Link to post
Share on other sites

While I haven't done this, I'm sure someone will be along with an answer shortly. (I'm curious too! This looks like something I'll file away in my "To Remember" folder!)

Share this post


Link to post
Share on other sites

I'd probably use mod_rewrite to do what you're asking. Add the following to the .htaccess file in your /public_html directory:

>RewriteEngine on
RewriteBase /
RewriteRule ^Blog/feed\.asp$ /feed/ [NC,R=301,L]
RewriteRule ^Blog/(.*)$ /$1 [NC,R=301,L]

The 'NC' indicates a 'no-case' (case-insensitive) comparison, the 'R=301' indicates a permanent redirect, and the 'L' indicates 'last rule' (stop processing mod_rewrite rules if this rule is matched).

 

Hope this helps...

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...