Apache2 redirect

Hi there,

I'm trying to redirect http://homepage.com to http://www.homepage.com

and also http://otherpage.com to http://www.homepage.com

I know how to do this with NGINX with a simple rewrite. Could someone please help me with apache2? I know it should be super easy.

Thanks!

3 Replies

There are a bunch of ways to do this. Usually what I would do is:

Create two separate vhosts - one for the www.homepage.com and one for homepage.com. Set up the www.homepage.com vhost like you normally would. Then the homepage.com vhost just needs to look like this:

 <virtualhost *:80="">ServerName homepage.com
    Redirect / http://www.homepage.com/</virtualhost> 

Here is the Documentation on the Redirect as mentioned above

http://httpd.apache.org/docs/2.2/mod/mod_alias.html

If you specify "Permanent", search engines are supposed to replace the URL they requested with the destination one.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct