Knowledgebase

Portal Home > Knowledgebase > Articles Database > Looking for a .htaccess expert!


Looking for a .htaccess expert!




Posted by zomex, 09-14-2010, 03:59 PM
Hello everyone, I have a couple of problems with redirects on both of my sites that may seem minor but really annoy me I would like my site to have the following redirects: - If my site is accessed via https:// I would like it to redirect to http://. For example if someone clicks on the order page WHMCS's .htaccess file will redirect them to the secure version. If the visitor then decides to click home or view a non-WHMCS page it will still use a secure connection. This issue is causing Google to index both secure and non-secure versions of each page - At the moment Google is indexing both /index.php and / versions of the same page which is showing as duplicate content. I would like all of the index.php pages to direct to the directory version. For example domain.com/company/index.php redirects to domain.com/company/ The biggest problem for me is that this problem is causing particular pages to be indexed twice. Here is my current .htaccess file: As you can see I have quite a few redirects after changing page names Thanks very much for any assistance! Jack

Posted by REMX, 09-14-2010, 08:46 PM
Just to avoid the obvious, check your URLS all lower case. Rewrites are case sensitive. You can add as many exceptions as you want using the [OR] to prevent that from being redirected to http.

Posted by zomex, 09-14-2010, 09:53 PM
Thanks very much for your reply. I'm still not quite following though. I will be willing to pay you $5 if you can provide the code to redirect every https:// (on non WHMCS pages) to http:// and redirect every /example/index.php pages to example/ Thanks very much! Jack

Posted by REMX, 09-14-2010, 10:02 PM
I don't want your money. Private Message me the list of URLs you want https and I will write it for you and reply here

Posted by zomex, 09-14-2010, 10:08 PM
Thanks mate although if I get this problem resolved I will be more than happy to pay you I thought there was some code where it will redirect to http:// everytime someone visits a page via https:// or does it have to be done on a per page basis? If so that will be a nightmare because I have so many pages. For example: redirects domain.com to http://www.domain.com/ without the need for redirecting every page separately. I found some code online but I couldn't get it to work. Thanks, Jack

Posted by REMX, 09-15-2010, 07:21 PM
As per our PMs, you want to redirect everything that isn't https://www.domain.com/clients to http. Place this .htaccess in your root folder: Please note that browsers cache redirects for a short period of time and you may not see the effects immediately. Please close your browser session (all windows/tabs individually) and then exit the browser and start it up again. In essence, just wait a minute

Posted by zomex, 09-15-2010, 08:04 PM
Thanks very much. The code works but I did notice 2 slight problems: 1) When i visit domain.com to doesn't redirect to http://www.domain.com. Could I also use my existing code somewhere to solve this problem? 2) This may just be my browser but for some reason my secure connection is broken on any /clients page when using that code. I am using relative file locations on all of the pages so that's not a problem. I'm thinking that it may be my browser: http://www.zomex.com/screenshot.jpg The WHMCS directory (clients) has its own .htaccess file so perhaps I don't need to worry about the clients directory in the code? Thanks so much! I post this issue before but didn't get a reply so this is great! Jack

Posted by zomex, 09-15-2010, 10:57 PM
Thanks very much for your help. I'm making some progress now. Here is my new .htaccess file: All that's left is to redirect any /index.php page to the folder for example: /company/index.php to /company/ /example/index.php to /example/ and to resolve the secure connection issue. Is there anyway to remove the /clients/ reference as it uses a different htaccess file? Thanks! Jack

Posted by zomex, 09-15-2010, 11:39 PM
Almost there now! I added the following code to my .htaccess file and it solved the /index.php problem: The only problem now is with the secure connection, I believe it's caused by this line: My new .htaccess file is as follows: Thanks very much! Jack Last edited by zomex; 09-15-2010 at 11:42 PM.

Posted by REMX, 09-15-2010, 11:49 PM
I don't understand why you need a separate htaccess file? If you put the code in ONE .htaccess file and place the file in your root folder; it will affect all subfolders. To set the default page add this to your .htaccess file: Also your htaccess does not appear to be correct. Please backup and remove all .htaccess files in all subdirectories. I've recreated and tested your whole .htaccess file for you: Comments are in # and you can leave them in the .htaccess file as it will not affect the operation of the file. As I said before, please be patient after uploading your htaccess file as the affects are not immediate. I have tested this on my own server and it works. The secure connection padlock was broken because you had mixed content in the page. Example: If I have a secure page https://secure.google.com/order.php and the page loads a logo from http://www.google.com/logo.png it will show a warning that the page is showing both secure and non secure items. Last edited by REMX; 09-15-2010 at 11:53 PM.

Posted by zomex, 09-16-2010, 12:01 AM
Hello, Thanks very much for your reply! The only reason why I have a separate .htaccess file is because /clients is WHMCS software. It has it's own .htaccess file for some url rewrites and takes care of the secure connection. I don't have any images/files using the full url, all of them use the relative url (/image.jpg). The problem seems to be due to the /clients reference in the root .htaccess file. Of course I can't remove the /clients/.htaccess file because it's used by WHMCS. -- Thank you very much for making adjustments including the notes. I will wait for your reply because I believe the code may be different knowing that /clients is for whmcs and needs the .htaccess file in that directory. I honestly want to pay you something at least for your help! Jack

Posted by REMX, 09-16-2010, 12:16 AM
According to Opera and Firefox, there's a problem with the server. It could be the certificate hasn't been correctly installed. http://img638.imageshack.us/img638/9246/zomex.png Let me try some more I'll reply here Last edited by REMX; 09-16-2010 at 12:21 AM.

Posted by zomex, 09-16-2010, 12:27 AM
Hello, Thanks for your reply. I tried both codes and everything worked apart from the /index.php redirect and the secure connection in WHMCS. I honestly think it's due to the: RewriteCond %{REQUEST_URI} !^(/clients/) lines. WHMCS handles the the secure connection in that .htaccess file. I have just removed the section that handles the redirect and the secure connection is working in WHMCS. By the way your computer screen is massive! My website looks like a stick Thanks very much for your patience! Jack

Posted by REMX, 09-16-2010, 01:02 AM
Sorry I thought you meant you HAD to type /soandso/index.php and /soandso/ wouldn't work. I'm not actually sure about that to be honest. I removed the code in my last post because it wasn't working but after waiting a few minutes and then checking back after 20 minutes, this definitely works: 52"

Posted by REMX, 09-16-2010, 01:12 AM
That error is coming up because you haven't installed your certificate properly. Please visit http://www.digicert.com/help/ and type https://www.zomex.com/ and you will see you have no intermediate or root certificate identity - this means you haven't installed your certificate properly. In that box type https://www.google.com and you should see something like that. I believe your certificate was issued by Equifax so it may be best to ask them for appropriate installation instructions.

Posted by zomex, 09-16-2010, 09:44 AM
Thanks for your reply. The SSL certificate has been installed properly. The reason why it doesn't show an issuer is because I have RapidSSL installed which is a cheap certificate. The first site that is also using a Rapid SSL cert that come to mind is mddhosting.com (sorry Mike), as you can see it also shows the same results as mine. Thanks, Jack



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read


Language:

Contact us