4 ms·
Ask HN: Help with this 301 redirect?
- jacquesm 17y agomod_rewrite will do this for you without any work on your part. Simply move your data and set up mod_rewrite to allow access to the data in its old location. You can 301 it but there are all sorts of pitfalls to avoid there. (not sure how much traffic you get from search engines but they tend to react badly to redirects if not done very carefully)
- brandnewlow 17y agoNot sure I follow 100%. I've got a drupal site configured so the groups have URLs like groupname.domain.com/ I'm using the subdomain module (http://drupal.org/project/subdomain http://drupal.org/project/subdomain) to create these "fake" subdomains. For a few reasons, I want to move to a structure like this: domain.com/groups/groupname I can switch off the subdomain module and change the paths to my existing groups to take the desired format. But I need to redirect all traffic going to the old URLs to the new ones. You're saying adding a Redirect to my htaccess isn't the best way to go? The guy over on stack overflow suggested a rule but it creates an infinite redirect loop.
- jacquesm 17y agoThe infinite redirect loop means that your rule is buggy, but that is the way to go. Probably you are matching too much. with the information you gave above I see a much simpler way to solve this: Set up your webserver (I'm assuming apache) to map www.yourdomain.com and yourdomain.com to one virtual host and .yourdomain.com to another. Then do the .htaccess in the root of the virtualhost associated with .yourdomain.com That way you can not make any infinite loops. good luck!
- brandnewlow 17y agoThanks. I'll look into that. I'm working on understanding the syntax of these rules, but it's been slow going.
- jacquesm 17y agomod_rewrite is one of the nastier apache modules, it's like a swiss army knife with 75 blades, there is always a way to do what you want but you'll end up with some blood on your shirt, even if you're careful. Don't sweat it, everybody goes through this phase when they start with mod_rewrite, then after a while it gets easier.