-1

I'm trying to set up .htaccess to force www for one folder of my site, but not the rest of it. Does anyone know how to do this?

ninjachicken1
  • 177
  • 1
  • 1
  • 8

1 Answers1

0

Use the solution from here:

.htaccess - how to force "www." in a generic way?

but put the .htaccess in the directory you want to force the www subdomain in. .htaccess files are only evaluated if they're in a directory that is in the directory where the file you're serving resides or any of its parent directories, so any other directories would be unaffected.

You should, however, probably not do that to begin with. Forcing the "www" subdomain is annoying enough as it is - and domains look sexier without that ;) - but only doing it for some directories is really going to confuse people.

Community
  • 1
  • 1
Magnus
  • 960
  • 4
  • 10
  • Tried that, didn't work. :( Also, I understand that this may be a bad idea, and it may not work as I intend it to. I'm doing this as a mad-science approach to temporarily fix a problem with a site where the frontend does not load when you log in - unless you put www in front of the url. – ninjachicken1 May 02 '13 at 14:39
  • so, what happened instead? or rather, what part of the site do you want the setting to apply to, what part did it apply to and where did you put your .htaccess? – Magnus May 02 '13 at 14:41
  • I'm putting it in the /system folder. And it didn't do anything. – ninjachicken1 May 02 '13 at 14:46
  • On the site, or locally? I mean, is it the right local path for whatever appears on your site? And are you using apache - with .htaccess processing enabled - as a web server, or maybe nginx or IIS or something weird? It's kind of hard to find the problem without quite a bit of additional information. All I know is that the solution I linked to works with a contemporary apache on my server ;). – Magnus May 02 '13 at 14:57
  • It's on the site, in the right local path, using apache. It might have something to do with the CMS, maybe this wasn't the right place to ask about this. – ninjachicken1 May 02 '13 at 15:15
  • a CMS might have disabled .htaccess processing on subdirectories, so yeah, that'd be the first place I'd look. Can you access the .htaccess file directly? I mean, like 'http://whatever.com/system/.htaccess'? CMS's typically also do a lot of redirecting themselves, so it might never reach the instructions in your .htaccess because things are being rewritten before that could be accessed. But if a CMS is involved it's probably best not to mess with its rewrites, so... – Magnus May 02 '13 at 15:24
  • Tried that and it's forbidden, which is probably for the best. I'll ask support about this. – ninjachicken1 May 02 '13 at 15:31