Hi Everyone,
I run a website off of a Ubuntu server (10.04 LTS, I think) with Apache, MySQL, and PHP. It serves both HTTP and HTTPS content. Currently, I have two main <directory> tags -- one for HTTP and one for HTTPS -- and I'm copying/pasting the same rewrite rules into both of them.
Is there a better way of doing this so I don't have to put the same rewrite rules in twice? Could I create a <directory> tag that would apply to both HTTP and HTTPS and put the rewrite rules in there?
Thanks for your help!
Here's a modified version of my Apache site configuration file (the real one has more rewrite rules):
Code:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddType video/webm .webm
Redirect 301 /pricing-and-signup/ /plans-and-pricing/
RewriteEngine on
RewriteRule ^tryv3/?$ /index.php [L]
RewriteRule ^TRYV3/?$ /index.php [L]
RewriteRule ^404/?$ /Error.php?Error=404 [L]
ErrorDocument 404 /404/
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
<VirtualHost xxx.xxx.xxx.xxx:443>
ServerAdmin webmaster@localhost
ServerName [REDACTED]
SSLEngine On
SSLCertificateFile [REDACTED]
SSLCertificateKeyFile [REDACTED]
SSLCertificateChainFile [REDACTED]
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
AddType video/webm .webm
Redirect 301 /pricing-and-signup/ /plans-and-pricing/
RewriteEngine on
RewriteRule ^tryv3/?$ /index.php [L]
RewriteRule ^TRYV3/?$ /index.php [L]
RewriteRule ^404/?$ /Error.php?Error=404 [L]
ErrorDocument 404 /404/
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
The rewrite rules that are repeated:
Code:
AddType video/webm .webm
Redirect 301 /pricing-and-signup/ /plans-and-pricing/
RewriteEngine on
RewriteRule ^tryv3/?$ /index.php [L]
RewriteRule ^TRYV3/?$ /index.php [L]
RewriteRule ^404/?$ /Error.php?Error=404 [L]
ErrorDocument 404 /404/