webgyrl Posted August 26, 2008 Posted August 26, 2008 Hi all, Something strange is going on with a redirect I am trying to do. I have set up a CMS test site on one of my main sites. This is basically a sub site to show clients how to use Joomla. I am trying to make sure that mysite.com redirects to www.mysite.com as that makes things like the WYSIWYG editor work better in Joomla. It's not re-directing for some strange reason. Any idea what I wrote wrong? >## OpenSEF Simplified htaccess File ## Can be commented out if causes errors #Options +FollowSymLinks ## mod_rewrite in use RewriteEngine On ## If Joomla is installed in the web server root ## RewriteBase / ## If Joomla is installed in a sub-directory ## RewriteBase /directory_name_here RewriteBase /client ## Begin 3rd-Party or OpenSEF Section #RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes## RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) index.php ## End 3rd-Party or OpenSEF Section ## Joomla Security Section (has nothing to do with SEF/SEO) ## Begin - Rewrite rules to block out some common exploits ## If you experience problems on your site block out the operations listed below ## This attempts to block the most common type of exploit `attempts` to Joomla! # Block out any script trying to set a mosConfig value through the URL RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR] # Block out any script trying to base64_encode crap to send via URL RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR] # Block out any script that includes a tag in URL RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR] # Block out any script trying to set a PHP GLOBALS variable via URL RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] # Block out any script trying to modify a _REQUEST variable via URL RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) # Send all blocked request to homepage with 403 Forbidden error! RewriteRule ^(.*)$ index.php [F,L] ## End - Rewrite rules to block out some common exploits ## Begin Joomla Re-write section rewritecond %{http_host} ^mysite.com/client [nc] rewriterule ^(.*)$ http://www.mysite.com/client$1 [r=301,nc] ## End Joomla Re-write section ## Begin PHP Section php_value file_uploads On php_value upload_max_filesize 13M php_value post_max_size 26M php_value max_execution_time 120 php_value max_input_time 120 php_value memory_limit 20M php_flag register_globals off ## End PHP Section Quote
TCH-Andy Posted August 26, 2008 Posted August 26, 2008 On the lines before the rewrite for the www redirect you have >RewriteRule ^(.*)$ index.php [F,L] where the L here means 'last' - i.e. Stop the rewriting process here and don't apply any more rewriting rules. Try removing that ,L ( I didn't check the rest of the code - but that seems the most obvious reason) Quote
webgyrl Posted August 27, 2008 Author Posted August 27, 2008 On the lines before the rewrite for the www redirect you have >RewriteRule ^(.*)$ index.php [F,L] where the L here means 'last' - i.e. Stop the rewriting process here and don't apply any more rewriting rules. Try removing that ,L ( I didn't check the rest of the code - but that seems the most obvious reason) Hi Andy! I tried that, but it's still not redirecting to www.sitename.com/client it just stays sitename.com/client I have bolded the part that is supposed to deal with the rewrite of the url in the code section below. Here is the revised HTACCESS file: >## OpenSEF Simplified htaccess File ## Can be commented out if causes errors #Options +FollowSymLinks ## mod_rewrite in use RewriteEngine On ## If Joomla is installed in the web server root ## RewriteBase / ## If Joomla is installed in a sub-directory ## RewriteBase /directory_name_here RewriteBase /client ## Begin 3rd-Party or OpenSEF Section #RewriteCond %{REQUEST_URI} ^(/component/option,com) [NC,OR] ##optional - see notes## RewriteCond %{REQUEST_URI} (/|\.htm|\.php|\.html|/[^.]*)$ [NC] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule (.*) index.php ## End 3rd-Party or OpenSEF Section ## Joomla Security Section (has nothing to do with SEF/SEO) ## Begin - Rewrite rules to block out some common exploits ## If you experience problems on your site block out the operations listed below ## This attempts to block the most common type of exploit `attempts` to Joomla! # Block out any script trying to set a mosConfig value through the URL RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR] # Block out any script trying to base64_encode crap to send via URL RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR] # Block out any script that includes a tag in URL RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR] # Block out any script trying to set a PHP GLOBALS variable via URL RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR] # Block out any script trying to modify a _REQUEST variable via URL RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2}) # Send all blocked request to homepage with 403 Forbidden error! RewriteRule ^(.*)$ index.php [F] ## End - Rewrite rules to block out some common exploits [b]## Begin Joomla Re-write section rewritecond %{http_host} ^mysite.com/client [nc] rewriterule ^(.*)$ http://www.mysite.com/client$1 [r=301,nc] ## End Joomla Re-write section[/b] ## Begin PHP Section php_value file_uploads On php_value upload_max_filesize 13M php_value post_max_size 26M php_value max_execution_time 120 php_value max_input_time 120 php_value memory_limit 20M php_flag register_globals off ## End PHP Section Thanks!!! Quote
SteveW Posted August 30, 2008 Posted August 30, 2008 Admittedly without looking closely at the rest of the code, I think the following might work for you. Ordinarily you'd do the non-www to www redirect straightaway before anything else. This sends the request back to the browser saying, "Please do it again, but with www". So I'm moving that rewrite up just after the RewriteEngine On. You'd also usually want to do that for the entire site, not just a folder like /client, so I removed /client. In addition, I suspect {http_host} only checks the parsed-out host name, and /client can't be part of that. That actually may be the reason the rewrite wasn't working, because it couldn't match /client as part of the host. I made a couple of other revisions as shown in red. You'll need to remove the extra spaces I added in the URL to prevent http... turning into a link. RewriteEngine On RewriteBase / rewritecond %{http_host} ^mysite\.com [nc] rewriterule ^(.*)$ http: //www . mysite.com/$1 [r=301,nc,L] Quote
webgyrl Posted August 31, 2008 Author Posted August 31, 2008 Hi All! Andy has sorted me out. Seems there was some conflict with the root .htaccess file, so I had to change things up to access the URL differently. It's all working now, thankfully. Now I'm pasting my hair back on my head. Thanks again! Quote
brianhulse Posted October 30, 2008 Posted October 30, 2008 I'm having a similar problem. Andy, or Webgyrl, could you please post the solution here? Thanks! Brian Quote
TCH-Andy Posted October 30, 2008 Posted October 30, 2008 Welcome to the forums Brian What do you have in your main .htaccess file and in any .htaccess in the subfolder ? The issue in the above case was because there was a conflict between the two different .htaccess files. Quote
brianhulse Posted October 30, 2008 Posted October 30, 2008 (edited) # -FrontPage- IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti* <Limit GET POST> order deny,allow deny from all allow from all </Limit> <Limit PUT DELETE> order deny,allow deny from all </Limit> AuthName www.domain.com AuthUserFile /home/user/public_html/_vti_pvt/service.pwd AuthGroupFile /home/user/public_html/_vti_pvt/service.grp Edited October 30, 2008 by brianhulse Quote
TCH-Andy Posted October 30, 2008 Posted October 30, 2008 HI Brian, I assume that this is the .htaccess in your public_html folder. There is no redirect in there. What are you trying to redirect to where ? ( if you don't want to say on a public forum, then please PM me ) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.