Hi:
greetings, hello, hola, sup?
I want my rewrite rules to change www.domain.com to www.domain.local or at least for the hosts file to send requests to my devel server. Code first and “why?” afterwards.
the vhost stuff:
#
# www.domain.local (/etc/apache2/sites-available/www.domain.local)
#
<VirtualHost 192.168.1.151:80>
ServerAdmin mike.dcc@gmail.com
ServerName www.domain.local
ServerAlias domain.local
# Indexes + Directory Root
DirectoryIndex index.php
DocumentRoot /var/www/www.domain.local
# CGI Directory
ScriptAlias /cgi-bin/ /var/www/www.domain.local/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>
# Logfiles
ErrorLog /var/www/www.domain.local/logs/error.log
CustomLog /var/www/www.domain.local/logs/access.log combined
</VirtualHost>
<VirtualHost 127.0.0.1:80>
ServerAdmin mike.dcc@gmail.com
ServerName www.domain.local
ServerAlias domain.local
# Indexes + Directory Root
DirectoryIndex index.php
DocumentRoot /var/www/www.domain.local
# CGI Directory
ScriptAlias /cgi-bin/ /var/www/www.domain.local/cgi-bin/
<Location /cgi-bin>
Options +ExecCGI
</Location>
# Logfiles
ErrorLog /var/www/www.domain.local/logs/error.log
CustomLog /var/www/www.domain.local/logs/access.log combined
</VirtualHost>
The .htaccess rewrite stuff:
<IfModule mod_security.c>
<Files async-upload.php>
SecFilterEngine Off
SecFilterScanPOST Off
</Files>
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /www.domain.local/
RewriteCond %{HTTP_HOST} !^www.domain.local$ [NC]
RewriteRule ^(.*)$ http://www.domain.local/$1 [R,L]
RewriteBase /domain.local/
RewriteCond %{HTTP_HOST} !^domain.local$ [NC]
RewriteRule ^(.*)$ http://www.domain.local/$1 [R,L]
# BEGIN WordPress
RewriteBase /domain.local/
RewriteRule ^index\\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /domain.local/index.php [L]
# END WordPress
The hosts file:
127.0.0.1 localhost
192.168.1.151 deimos deimos.local domain.local www.domain.local
#this line below seemed to work but my CSS got trashed - no styling at all
192.168.1.151 domain.com www.domain.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Note: Perhaps after several attempts to make this work, I left a glaring error in one of the above files. If so, fixing it might not help.
Simple reason why I want this:
My wordpress site is hosted. wordpress stores URLs in a database. The hosted database contains the content. An export from hosted / import to local will still bring in .com URLs. I want to see my code changes happening locally with the real content from the hosted DB, not some lorem ipsum stuff that lacks the things I’ve added - some of which is used for ACL (access control). This is a must (i.e., using the external database while the local code executes). And until I click a link in the main nav (again, that comes from the WP DB) it works. The code is self aware. I figgers out whether it’s executing on the host’s server or mine and whether I want the local database or external.
I’m tired of waiting on git pushes every time I make a change.
I HAVE tried changing the local site tree from www.domain.local to www.domain.com (would need to change the hosts file every time I switch, but that isn’t a bad compromise if there’s no other solution) along with changes to the vhost code and rewrite rules but I’m not sure I’ve tried all the combos and permutations of that nightmare.
Yes, I tell apache2 to reload the config when I change the vhost stuff. And firefox seems to handle the hosts file changes without a restart (surprise!)
Thanks in advance for anyone who can help. Tell you what… if you like, when my partner and I gear up for first round funding, we’ll send the winning solution provider(s) a free t-shirt 8) Yup. Folks who help out get at least a t-shirt.
TIA again
Mike
P.S. HostMonster sets their server for local (mountain) time and you can forget MySQL timestamps from reflecting UTC. Beware!