LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 11-12-2011, 04:05 AM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Apache on Squeeze: very basic rewriting doesn't seem to do anything


Hello

This is essentially a re-post of a Webmaster World post that has gone unanswered for 36+ hours. Maybe the Debian-specific nature of the question put off answerers.

After much experimentation, I have assembled a very basic test of rewriting but it doesn't seem to do anything.

On a Debian Squeeze system, I re-initialised Apache by:
Code:
# aptitude purge apache2 apache2-utils apache2.2-bin apache2.2-common
# rm -fr /etc/apache2 /var/www /var/log/apache2
# aptitude -y install \
apache2 apache2-mpm-prefork \
libapache2-mod-perl2 libapache2-mod-php5 \
libapache2-mod-python libapache2-reload-perl \
nagios3 nagios3-cgi
# a2enmod rewrite
Note: the installation command also restores packages that were removed during the purge because they depend on the re-initialised Apache packages.

Created /etc/apache2/conf.d/rewrite_tests:
Code:
LogLevel        debug
LogFormat       "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\" \"%e\"" combined
Options         All

RewriteEngine   On
RewriteLog      /var/log/apache2/rewrite.log
RewriteLogLevel 7
RewriteRule     ^ - [env=FOO:BAR]
RewriteRule     ^(.*)$ http://www.linuxquestions.org/ [L,R,NE]
Notes:
  1. The LogFormat re-definition adds envar reporting.
  2. The first RewriteRule only sets envar FOO.
  3. The second RewriteRule is based on the example given in the Apache RewriteRule documentation in the Canonical Hostnames section, for the port 80 example.
After restarting Apache:
  1. /var/log/apache2/rewrite.log is created.
  2. Browsing http://<server ID by name or IP address> displays the as-installed /var/www/index.html, not Linux Questions as intended. Then ...
  3. /var/log/apache2/access.log shows "-" in the %e field, so the FOO envar was not set.
  4. /var/log/apache2/rewrite.log is empty.
  5. /var/log/apache2/error.log shows no errors, only startup messages.
Does the evidence support the theory that rewriting is not doing anything?

Could /etc/apache2/conf.d/rewrite_tests be better devised to test basic rewriting functionality?

How can rewriting functionality be enabled?

Best

Charles
 
Old 11-12-2011, 01:17 PM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Solved, thanks to Nominal Animal's post in another LQ thread which included: "Because of the way VirtualHosts are configured for Apache on Debian, RewriteRule only works within a Directory directive".

AFAIK he was thinking of the as-installed /etc/apache2/sites-enabled/000-default which is a symlink to /etc/apache2/sites-available/default and contains
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
	</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 ${APACHE_LOG_DIR}/error.log

	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn

	CustomLog ${APACHE_LOG_DIR}/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>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem rewriting Apache/GeoIP poard Linux - Server 0 01-25-2010 09:38 AM
Drapes 0.5.2-3.1 doesn't do anything on my Debian Squeeze machine angelus353 Linux - Software 0 01-14-2010 11:38 AM
Apache - rewriting links dlugasx Linux - Server 3 04-15-2009 06:51 AM
Apache: Need helping rewriting URLs hex1a4 Linux - Server 1 05-20-2008 09:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 09:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration