This sends the browser into an ‘endless’ loop. I’m not sure why. Couple of things - this is an additional domain on the server in a sub-folder located in the public_html directory.
Also, since it’s a wordpress site and I have modified permalink structure to human-readable urls, this is the code that wordpress added to the .htaccess file (this is below the above lines):
Did you use the www redirection before or after the WP code?
You will find that
RewriteEngine on
RewriteCond %{HTTP_HOST} ^kelownamotorcycletours.com [NC]
RewriteRule (.*)$ http://www.kelownamotorcycletours.com/$1 [R=301,L]
# BEGIN WordPress
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
works. However, because $1 is already available to you as %{REQUEST_URI}, I’d use
RewriteEngine on
RewriteCond %{HTTP_HOST} ^kelownamotorcycletours.com [NC]
RewriteRule[COLOR="#800080"][B] .? [/B][/COLOR]http://www.kelownamotorcycletours.com[COLOR="#800080"][B]%{REQUEST_URI}[/B][/COLOR] [R=301,L]
# BEGIN WordPress
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
instead.
The one thing that you NEVER want to do is make the same test over and over again for each and every @#$% request, i.e., the WordPress folks added the <IfModule> so the unwary would not take their server down for 500 errors (unrecognized code will cause .htaccess to stop your website from functioning). That is emphasized by my …
[standard rant #4][indent]The definition of an idiot is someone who repeatedly does the same thing expecting a different result. Asking Apache to confirm the existence of ANY module with an <IfModule> … </IfModule> wrapper is the same thing in the webmaster world. DON’T BE AN IDIOT! If you don’t know whether a module is enabled, run the test ONCE then REMOVE the wrapper as it is EXTREMELY wasteful of Apache’s resources (and should NEVER be allowed on a shared server).[/indent][/standard rant #4]
Other than that, there was no reason your code should not have worked IF in the proper order.
I copy-pasted what you posted and still does not work.
This is the error that I get:
The page isn’t redirecting properly: Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
I wonder if a different htaccess file in a directory higher up is interfering or something…
What was in my last post is correct but I cannot see what else you have going on (i.e., Redirect statements in this .htaccess or any code in .htaccess in the path (note, though, that /index.php in the last RewriteRule is directing to (the root of the server THEN) the DocumentRoot of the domain, not the subdirectory which you’re hinting is the location of this .htaccess.
Well, this site is an ‘addon domain’ sitting in its own folder in the public_html directory.
Now, the main site for the hosting account is not in the public_html directory. It’s actually, much like the addon domain, in a directory of its own that is located in the public_html directory (for a cleaner file structure).
As hosting accounts by default place the main website in the public_html directory, I have an htaccess file in the public_html directory that directs requests for the main website to the correct folder. Maybe that has something to do with it? I can post the content of that htaccess file if you’d like to see it.
I guess it would depend upon the content of the .htaccess file which gets the request first. That, of course, is determined solely by the DocumentRoot as identified in the httpd-vhosts.conf file. If that’s directed at the physical location of the .htaccess discussed above, then nothing else is in play (and you must have something else going on in your .htaccess file) OR mod_rewrite (default is NOT enabled) or .htaccess (default is enabled) is not enabled.
where is the httpd-vhosts.conf file typically located? I’ve clicked through a number of folders but haven’t found it…I wonder if it’s something I’ll need to ask the server company to take a look at…
Actually, I believe that it’s a redirection but it could require the elimination of the subdirectory and then re-creation - PITA but something which (I hope) the cPanel people will look at adding to their fine control panel.
I’m sorry, I’m not sure I fully understand your response. So your hunch is that the redirection itself is a problem? Or something with a conflicting htaccess file? Why would recreating a subdirectory help?
No, cPanel hasn’t considered that some webmasters don’t think things through before adding an add-on domain (or subdomain). I am the perfect example of that and I’ve had difficulties going back and redirecting (sub)domains to a different DocumentRoot. I recall that there is a cPanel module which allows redirection of a subdomain to a different (physical) location (i.e., changing the physical name of the subdirectory used). That’s all.
Again, though, if you can’t find that module, the safest (well, cleanest) way to handle the change would be to (1) SAVE the contents of the current directory, (2) delete the old (sub)domain, then (3) create the new (sub)domain in the location you want it to be (like the physical location of the SAVED files from the old (sub)domain).