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/
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:The regex
^/$
ensures, only locations which are exactly/
will be redirected and the[L]
tells apache to stop doing any rewrites after this lines.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.