CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Apache configuration (http://www.codingforums.com/forumdisplay.php?f=69)
-   -   HTACCESS problem - loop error (http://www.codingforums.com/showthread.php?t=186739)

vorl 01-14-2010 08:53 PM

HTACCESS problem - loop error
 
Hey guys

Im stuck with a problem...i'll explain the issue.

I published my website and the path was something like www.example.com/example.php and it was indexed by google. I have now redone my directories so the path is now www.example.com/uk/example.php

So when a visitor goes to example.com it should go to example.com/uk/
As google has already indexed the old path, im assuming I need a 301 redirect to phase out the old path and introduce the new path...correct me if im wrong?

Ive tried the following basic 301 redirect...but it returns a 'indefinate loop'.

Code:

Redirect 301 / http://www.example.com/uk/

Please someone let me know what im doing wrong...ive spent hours searching and found nothing! :(

Thanks!

angst 01-15-2010 02:37 AM

try this;

Code:

Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.domain.com/dir/$1 [R=301,L]


vorl 01-15-2010 03:28 AM

Thanks for that...

I tried it and for some reason the page doesnt seem to be loading correctly. I went to www.webpagetest.org and tested the website.

Basically i have a subdomain (ie. images.example.com which is located at example.com/images). The htaccess seems to be causing the website to load whatever is in the subdomain twice (ie. once from images.example.com and again from example.com/images).

Any ideas to how to fix this?

zcrafts 01-15-2010 02:03 PM

Hello,

Can you update whats the error you are getting to help you better.

vorl 01-15-2010 04:27 PM

Theres no actual error. Heres whats happening:

Scripts are located at 'http://script.example.com/script.js' whose actual path is 'http://www.example.com/script/script.js'.

According to webtestpage.org, 'http://script.example.com/script.js' is being loaded aswell as 'http://www.example.com/uk/script/script.js', the latter doesnt exist.

So i assume the htaccess above rewrites all urls under example.com to example.com/uk/. That is why when the page loads it doesnt look/behave correctly.

So what I suppose I need is to force (if possible) the htaccess file to just work in the root and not in the subdirectories? Is this possible? Or is there anything else I can do...maybe force the script directory to always reference the subdomain??

Hope this is clear, let me know if it isnt. Thanks!

vorl 01-16-2010 04:23 AM

Update:

I found some code on the net which excludes sub domains from the rewriterule:

Code:

RewriteCond %{HTTP_HOST} ^scripts\.example\.com
RewriteRule .* – [L]

However now when I test it on webtestpage it gives me a '500' error for the files located on the subdomain!

What is going on here? Anyone know who to resolve this? Please....

vorl 01-17-2010 05:51 AM

Solved! For anyone interested, I missed a line of code (RewriteBase /) out.

Heres what I eventually used:

Code:

Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^script\.example\.com
RewriteRule .* - [L]

RewriteCond %{HTTP_HOST} !^(.*)\.example\.com/uk/$ [NC]
RewriteRule ^(.*)$ http://www.example.com/uk/$1 [R=301,L]

Thanks! :)


All times are GMT +1. The time now is 06:11 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.