gilesht
By:
gilesht

mod_rewrite : changing ip address to www.

February 27, 2015 1.4k views

Hi, so I've read through your documentation and also through posts and I'm still unclear of the problem. Can I get your help please. Goes like this.

  1. I'm forwarding my domain "thewebmadesimple.com" to http://178.62.21.147/thewebmadesimple.com - which is my droplet DO-07

  2. I've set up mod_rewrite to /var/www/thewebmadesimple.com but I cant find out how to substitute the 178.62.21.147 to www (I want to end up with www.thewebmadesimple.com)

sorry if this is a stupid question (guess I'm stupid).
thanks in advance

2 comments
  • It sounds like you might be over-complicating this a little, but I do not know the whole picture, so just bear with me:

    1. is there a reason you are "forwarding" your domain rather than just setting the top-level a-record to your droplet?

    2. can you post your site config file? It should be in /etc/apache2/sites-enabled

  • Hi, thanks for taking the interest... looks like this

    <virtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName thewebmadesimple.com
    ServerAlias www.thewebmadesimple.com
    DocumentRoot /var/www/thewebmadesimple.com

    <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    Order allow, deny
    allow from all
    </Directory>
    </VirtualHost>

2 Answers

Hi, thanks for taking the interest... looks like this

<virtualHost *:80>
ServerAdmin webmaster@localhost
ServerName thewebmadesimple.com
ServerAlias www.thewebmadesimple.com
DocumentRoot /var/www/thewebmadesimple.com

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow, deny
allow from all
</Directory>
</VirtualHost>

  • your directory needs to be corrected. Like:

    <VirtualHost *:80>
          ServerAdmin webmaster@thewebmadesimple.com
          ServerName www.thewebmadesimple.com
          ServerAlias   thewebmadesimple.com
          DocumentRoot /var/www/thewebmadesimple.com
          ErrorLog ${APACHE_LOG_DIR}/error.log
          CustomLog ${APACHE_LOG_DIR}/access.log combined
    
        <Directory /var/www/thewebmadesimple.com>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
                    Require all granted
        </Directory>
    
    </VirtualHost>
    
    

    You will need to reload apache afterwards:

    sudo service apache2 reload
    

Sierracircle - thanks for your help on this.

I had to go round the houses a few times, learnt loads, turns out that I was forwarding my domain incorrectly. Once I'd covered that it all fell into place.

thanks for your time - appreciate it

Have another answer? Share your knowledge.