Forum Moderators: phranque

Message Too Old, No Replies

Redirection problems with site re-organization

         

LeeU

6:45 pm on Dec 14, 2006 (gmt 0)

10+ Year Member



I'll try to make this as easy as I can. Up until recently, I had a Web site which used the address "http://www.quux-foo.org/emet/". Below that were a few directories. I recently obtained a domain name and set it up as an addon domain which pointed to that directory. I also set up a redirection in the .htaccess file for "quux-foo.org". I had thought that I could just put the following in the file and that would be enough:

redirect 301 /emet http://www.example.org

Well, for some reason, it wasn't, I had to add additional redirects (see below). Now, I am getting errors that leave out the directory I redirected to. For instance, I had a file with the path:

http://www.quux-foo.org/emet/analysis/greatlie.php

Now, for some reason, I am getting errors that point to non-existent files at (and all the other sub-directories):

http://www.quux-foo.org/analysis/greatlie.php

The code above should be redirecting it. Below is my .htaccess file. Any ideas of what is happening?


redirect 301 /emet http://www.example.org
redirect 301 /emet/analysis/ http://www.example.org/analysis/
redirect 301 /emet/documents/ http://www.example.org/documents/
redirect 301 /emet/views/ http://www.example.org/views/

RewriteEngine on

RewriteRule ^current\.php$ http://www.example.org/current.php
RewriteRule ^current\.htm$ http://www.example.org/current.php

RewriteBase /
RewriteRule ^(.*)\.htm$ $1 [C,E=WasHTML:yes]
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.*)$ $1.php [S=1,R]
RewriteCond %{ENV:WasHTML} ^yes$
RewriteRule ^(.*)$ $1.htm

AddType text/html .html .htm

IndexIgnore *

RewriteRule ^weblog/?(.*)$ /cgi-bin/blosxom.cgi/$1

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

AddHandler server-parsed .html .htm

ErrorDocument 400 /errorpage.php
ErrorDocument 401 /errorpage.php
ErrorDocument 403 /errorpage.php
ErrorDocument 404 /errorpage.php
ErrorDocument 500 /errorpage.php

<Files 403.shtml>
order allow,deny
allow from all
</Files>

<Files php.ini>
Order allow,deny
Deny from all
</Files>

SetEnv TZ EST5EDT

[edited by: jdMorgan at 11:25 pm (utc) on Dec. 14, 2006]
[edit reason] No URLs, please. See Terms of Service. [/edit]

jdMorgan

2:50 pm on Dec 15, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looking at this, one potential problem is that the code may not be executing in the order you expect. When processing configuration files, each Apache module will parse the file and respond only to the directives that it understands. Therefore, although directives for each module execute in the given order, the execution order of directives specific to each module cannot be controlled. Therefore, for example, all of your "Redirect" directives will likely execute first, followed by all of your mod_rewrite directives.

Module execution order is controlled by the LoadModule list order in Apache 1.x, and by an internal priority scheme in Apache 2.x.

So, if you are seeing strange results, it might be a good idea to do two things: First comment out all but one set of RewriteRule and Redirect directives, so that you are testing only one small representative set of URLs. Then try rewriting the code so that all redirects and rewrites use mod_rewrite, instead of using a mixed mod_rewrite/mod_alias solution.

Once you get the one case working, it will be easy to implement the same approach for the other sets of URLs.

"Divide and conquer> Simple is good."

Jim

LeeU

1:59 am on Dec 20, 2006 (gmt 0)

10+ Year Member



Seeing as I really don't know what I am doing, that's kind of like playing the lottory, don't you think? One chance in how many millions?

Anybody else have any ideas?