views:

818

answers:

1

I have a series of RewriteRules in .htaccess for my site which I'm in the process of restructuring.

# Requests for http://example.com/contents/section/4/48/
# get redirected to http://example.com/courses
RewriteRule ^content/section/4/48/$ /courses [R=301,L]

This is working fine, except that right now I've got the new and unreleased site sitting in a /new/ subdirectory, and so while testing, I need the rules to redirect to /new/courses instead of /courses... basically I just want it to redirect to a URL relative to where the .htaccess file is.

/home/user/www/new/.htaccess --> redirect to /new/courses
/home/user/www/.htaccess --> redirect to /courses

It doesn't seem right that I'd have to change each line in the /new/.htaccess file when I move it to root directory. Is there something I'm missing?

A: 

Untested - but you should simply be able to remove the "/" from your target, i.e.

RewriteRule ^content/section/4/48/$ courses [R=301,L]
mjy
unfortunately no, that doesn't work. it ends up adding the filesystem path to the url like this: example.com/home/user/www/new/courses
nickf