homepage Welcome to WebmasterWorld Guest from 54.163.72.86
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

    
301 redirect frustration
mgpapas




msg:3066302
 7:01 pm on Aug 30, 2006 (gmt 0)

Ok I'm going crazy I am trying to do what I keep reading everywhere is a simple procedure.
I want to redirect domain.co.uk/test.html to [otherdomain.com...] I'm running Apache/2.0.52 (CentOS)

I host 20+ domains on my server so I use virtual hosts configured like so.

<VirtualHost www.domain.co.uk>
DocumentRoot /home/domains/domain_co_uk
ServerName www.domain.co.uk
<Directory "/home/domains/domain_co_uk">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

The first thing I tried was .htaccess like so

Redirect 301 /test.html [domain.com...]

and put in the domains root directory /home/domains/domain_co_uk

I even tried to redirect the entire domain using mod_rewrite but it seems the .htaccess file is totally ignored.

Next I tried

Redirect permanent /home/domains/domain_co_uk/test.html [domain.com...]

in the httpd.conf and restarted apache as instructed.

AGAIN nothing happened.

Is my server broke or what? I hope someone reads this and can tell me what I could possibly do to solve this I have googled this problem to death and can't find anything.

 

Caterham




msg:3066336
 7:24 pm on Aug 30, 2006 (gmt 0)

Next I tried

Redirect permanent /home/domains/domain_co_uk/test.html [domain.com...]

in the httpd.conf and restarted apache as instructed.


You must use an url-path, not a filename.

<VirtualHost www.domain.co.uk>
DocumentRoot /home/domains/domain_co_uk
ServerName www.domain.co.uk
[b] Redirect 301 /test.html http://www.otherdomain.com/test.php [/b]
<Directory "/home/domains/domain_co_uk">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

mgpapas




msg:3066407
 8:25 pm on Aug 30, 2006 (gmt 0)

I'm not the religious type but god bless you it worked.
The problem I had was I wasn't putting the httpd.conf 301 redirect inside the <virtualhost>

Apache's instructions just say:

# Redirect allows you to tell clients about documents which used to exist in
# your server's namespace, but do not anymore. This allows you to tell the
# clients where to look for the relocated document.
# Example:
# Redirect permanent /foo http://www.example.com/bar

So based on that I just put

Redirect permanent /home/domains/domain_co_uk/test.html [domain.com...]

below there which of course didn't work.

I may seem like a total noob but all my other sites are php and a php 301 redirect is very simple.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved