htaccess Elite

.htaccess tutorial


All times are UTC [ DST ]





Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Redirection problems with site re-organization
PostPosted: 18 Dec 2006 20:05 
Offline

Joined: 18 Dec 2006 19:33
Posts: 3
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.shamar.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 "shamar.org". I had thought that I could just put the following in the file and that would be enough:

Code:
redirect 301 /emet http://www.emetnews.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:

Code:
http://www.shamar.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):

Code:
http://www.shamar.org/analysis/greatlie.php


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

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

RewriteEngine on

RewriteRule ^current\.php$ http://www.emetnews.org/current.php
RewriteRule ^current\.htm$ http://www.emetnews.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 America/Miami
SetEnv TZ EST5EDT



Lee


Top
 Profile  
 
 Post subject:
PostPosted: 22 Dec 2006 05:58 
Offline
User avatar

Joined: 25 Sep 2006 04:48
Posts: 242
Yes this is a good question!


change
Code:
redirect 301 /emet http://www.emetnews.org
redirect 301 /emet/analysis/ http://www.emetnews.org/analysis/
redirect 301 /emet/documents/ http://www.emetnews.org/documents/
redirect 301 /emet/views/ http://www.emetnews.org/views/


to
Code:
RedirectMatch 301 /emet/(.*) http://www.emetnews.org/$1

or if that doesn't quite work try this
Code:
RedirectMatch 301 /emet(.*) http://www.emetnews.org$1


and be sure to let us know if that fixes it..


Top
 Profile  
 
 Post subject:
PostPosted: 12 Jan 2007 16:48 
Offline

Joined: 18 Dec 2006 19:33
Posts: 3
Sorry I didn't get back to you. It was just a matter of changing the "RewriteBase /" to the correct directory, since it was in a sub-directory. Thanks!

I do have one other question. In using the portion:

Code:
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


how would I also add for files with an ".html" extention? Do I need to just rewrite it again or can I add to what is already there?

(BTW, I am Lee with Jupitermedia that contacted you the other day - small world!)



Lee


Top
 Profile  
 
 Post subject:
PostPosted: 16 Jan 2007 12:23 
Offline
User avatar

Joined: 25 Sep 2006 04:48
Posts: 242
Hey Lee! Try this!

Code:
RewriteBase  /
RewriteRule  ^(.*)\.(htm|html)$ $1 [C,E=WasHTML:$2]

RewriteCond  %{REQUEST_FILENAME}.php -f
RewriteRule  ^(.*)$ $1.php  [S=1,R]

RewriteCond  %{ENV:WasHTML}  ^htm$
RewriteRule  ^(.*)$  $1.htm

RewriteCond  %{ENV:WasHTML}  ^html$
RewriteRule  ^(.*)$  $1.html


Top
 Profile  
 
 Post subject:
PostPosted: 16 Jan 2007 16:11 
Offline

Joined: 18 Dec 2006 19:33
Posts: 3
Thanks! I'll give it a try and let you know.



Lee


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: MSN [Bot], MSNbot Media and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB