Forum Topic: Redirect Subdirectory

Forum: .htaccess Forum : Redirecting • Posted by John Harcourt • Updated:


Just got the book today ….

Quick question if you do not mind.

We have a blog as a subdirectory ,we do not have a htaccess within that sub-directory .. (should we?)

I cant figure out how to remove the .php from the index page within the blog …

Its done on the main website … but cant for the life of me get it done with the subdirectory

I am sure its straight forward, its just I am a little dim :-)

Thanks for your help and the great book, I would have loved to get a hard copy, $30 delivery to Ireland frightened me :-)

Best Regards


3 Replies to “Redirect Subdirectory”

Posted by Jeff Starr

Hi John,

Absolutely, what are the URL(s) involved specifically (both target and destination) and I’ll do my best to help.

For the book, yes shipping is expensive these days, as are most things ;) We may be able to save you some money on shipping if you want to send the zip code to us at

Posted by John Harcourt •

Hi Jeff

Thanks for the reply ,apologies for the late reply, I had a rather long weekend …

I’d rather not post the actual URL but if you need it I happily PM it.

Below is the structure though

URL – (contains a htaccess that redirects non www to www and removes index.php file name to avoid duplicate content

I have a blog created within a folder, so the blog is This contains an index page … Which is

The blog folder does not contain a .htaccess file ..

I have tried adding one to remove the index.php form

As it stands at the moment, the blog can be accessed from

I wish for the to be redirected to

I hope that makes sense and you can help out

This is what I tried, I created a new .htaccess file and added it to the blog folder, but it didn’t work

#Redirect no-www to www
RewriteCond %{HTTP_HOST} !www\$ [NC]
RewriteRule ^(.*)$$1 [L,R=301]
RewriteRule ^index\.php$ [L,R=301]

Thanks again


Posted by Jeff Starr

Hi John,

How about something like this:

RewriteCond %{HTTP_HOST} ^/blog/index.php$ [NC]
RewriteRule .* [L,R=301]

I would first try this before/after existing rules in the root .htaccess file, and then if that doesn’t work, add them to .htaccess in the /blog/ directory.

It should work as-is, but some fine-tuning may be required, depending on the actual URL(s).

Let me know how it goes!