Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have my main domain URL mapped to the root of my server

I have a wordpress installation installed under /blogs/techblog

I want to direct any traffic coming in at jameselsey.co.uk to > jameselsey.co.uk/blogs/techblog

If I point the URL itself to the subdirectory then my installation will not work

Is it possible to do this with an .htaccess file in the root of my server?

I have tried the following, but it creates an "endless loop"

Redirect 301 / http://www.jameselsey.co.uk/blogs/techblog/
share|improve this question
add comment

2 Answers

I think the problem is, that Redirect also redirects sub-paths, like /foo or in this case /blogs/techblog and appends it to the new location. This may be helpful, because if you move a whole website to another location (as the HTTP status already says Moved Permanently), old links still work.

In your case, this behaviour is not very helpful, but you can try using mod_rewrite instead:

RewriteEngine on
RewriteRule  ^/$    /blogs/techblog  [L]

The regex ^/$ ensures, only locations which are exactly / will be redirected and the [L] tells apache to stop doing any rewrites after this lines.

share|improve this answer
add comment

Did you initially install the blog at jameselsey.co.uk? I'm guessing you did, because Wordpress will redirect to the server name it has. The way to fix it is to move it back, login to your wp-admin, change the server name to http://www.jameselsey.co.uk/blogs/techblog/, and move it back. There's probably a cleaner way to do it inside the database/configuration files.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.