LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Apache redirect results in endless loop (https://www.linuxquestions.org/questions/linux-software-2/apache-redirect-results-in-endless-loop-714425/)

jnojr 03-25-2009 04:53 PM

Apache redirect results in endless loop
 
I want to have requests to http://my.server/directory1/ wind up displaying http://my.server/directory1/test.xsd I tried adding test.xsd to DirectoryIndex in httpd.conf, but that didn't work. I tried adding test.xsd to DirectoryIndex in php.conf but that didn't work, either. I tried a Redirect in httpd.conf that said:

Redirect /directory1 http://my.server/directory1/test.xsd

which resulted in a URL of http://my.server/directory1/test.xsd...t.xsd/test.xsd

and one in .htaccess in directory1/ that said:

Redirect / http://my.server/directory1/test.xsd

But that winds up with my browser trying to access http://my.server/directory1/test.xsd...tory1/test.xsd

and:

Redirect Loop

Firefox has detected that the server is redirecting the request for this address in a way that will never complete.



What do I need to do to make this work?

acid_kewpie 03-25-2009 05:07 PM

Either percevier with the DocumentIndex angle, or just add an index.html to contain a meta refresh to redirect to it that way.

rjlee 03-25-2009 06:06 PM

Quote:

Originally Posted by jnojr (Post 3487746)

Redirect only does simple prefix matching, so it can't be used to redirect a URL that starts with /directory1 as it would tell the browser to make a new request at the correct URL, but then it would redirect that — resulting in your loop.

You need a redirect rule that matches the exact path; I'd use RedirectMatch, which is similar to Redirect but matches on Regular Expressions:

Code:

RedirectMatch /directory1/?$ http://my.server/directory1/test.xsd
The ? makes the ending / optional (to redirect both /directory1 and /directory1/), and the $ means to match the end of the string.

For details on RedirectMatch, see http://httpd.apache.org/docs/1.3/mod...#redirectmatch

Hope that helps,

—Robert J Lee

grizly 03-25-2009 08:14 PM

Try this in your .htaccess

AddType text/html .xsd
DirectoryIndex file.xsd

<Files .htaccess>
order allow,deny
deny from all
</Files>

http://httpd.apache.org/docs/2.2/howto/htaccess.html

Make sure you have http://httpd.apache.org/docs/2.2/mod...#allowoverride set correctly. (Its probably denied globally (for performance) so you need to allow htaccess files, check your logs for any errors, apache is usually very helpful!


All times are GMT -5. The time now is 01:17 PM.