Rewrite IP address to show URL
https://stackoverflow.com/questions/22162202
Question
I have a subdomain on my server stack.zachstarnes.com and it is currently pointing to a Digital Ocean droplet. When you type in the above address in a browser it ends up showing the IP address that its redirecting to and I would like it to show stack.zachstarnes.com.
I added a .htaccess file in the same directory as the index.php file that has:
RewriteCond %{HTTP_HOST} ^107\.170\.67\.157
RewriteRule (.*) http://www.stack.zachstarnes.com/$1 [R=301,L]
but this does not work because it still shows the IP address. I also made sure I went into the .conf file and change AllowOverride None
to AllowOverride FileInfo
am I doing something wrong? Any help would be great!
here is the error log
[Tue Mar 04 02:39:08 2014] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Mar 04 02:39:08 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/bin/suexec)
[Tue Mar 04 02:39:08 2014] [notice] Digest: generating secret for digest authentication ...
[Tue Mar 04 02:39:08 2014] [notice] Digest: done
[Tue Mar 04 02:39:08 2014] [notice] Apache/2.2.26 (Unix) mod_ssl/2.2.26 OpenSSL/1.0.1e DAV/2 configured -- resuming normal operations
[Tue Mar 04 02:40:27 2014] [error] [client 24.126.213.31] File does not exist: /srv/http/favicon.ico
[Tue Mar 04 02:50:58 2014] [notice] caught SIGWINCH, shutting down gracefully
[Tue Mar 04 02:50:59 2014] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Tue Mar 04 02:50:59 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/bin/suexec)
[Tue Mar 04 02:50:59 2014] [notice] Digest: generating secret for digest authentication ...
[Tue Mar 04 02:50:59 2014] [notice] Digest: done
[Tue Mar 04 02:50:59 2014] [notice] Apache/2.2.26 (Unix) mod_ssl/2.2.26 OpenSSL/1.0.1e DAV/2 PHP/5.5.9 configured -- resuming normal operations
and here is the relevant code from the httpd.conf file
#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/srv/http">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow