Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trailing slashes on URL rewrite in Apache

Status
Not open for further replies.

jsdf

Technical User
Nov 5, 2007
1
0
0
US
Hi,
I recently moved my rewrite rules from .htaccess to /etc/apache2 as I have root access. However, what I've noticed is that, after moving the rules, I now receive double trailing slashes when any of the rules are activated.
For example, will be rewritten to
I am running Apache 2 with Drupal 5.1 on Debian Linux.

Does anyone have suggestions on how to fix this? I have posted contents of the site's top-level configuration file, as well as the .htaccess file, below.

Note that, after I moved the rewrite to the top-level configuration file, .htaccess is now untouched from the default Drupal configuration.

Thank you,
Jason

Contents of /etc/apache2/sites-enabled/www:
Code:
NameVirtualHost *:80

<VirtualHost *:80>

    DocumentRoot    /var/[URL unfurl="true"]www/wdnt_test[/URL]
    ServerName      [URL unfurl="true"]www.mysite.com[/URL]
    ServerAlias     [URL unfurl="true"]www.myoldsite.com[/URL]
    ServerAlias     mysite.com
    ServerAlias     myoldsite.com
    ServerAlias     test.mysite.com
    ServerAlias     test.myoldsite.com

    ErrorLog        /var/log/apache2/wdnt-error.log
    TransferLog     /var/log/apache2/wdnt-access.log

    CustomLog       /var/log/apache2/wdnt-combined.log combined

    <Directory "/var/[URL unfurl="true"]www/wdnt_test">[/URL]
        AllowOverride All
        Options +ExecCGI
        AddHandler cgi-script .cgi .pl
    </Directory>

    Alias /awstats-icon/ "/usr/share/awstats/icon/"
    Alias /awstatscss "/usr/share/doc/awstats/examples/css"
    ScriptAlias /awstats /usr/lib/cgi-bin/
    <Directory /usr/lib/cgi-bin>
        AuthName "CGI restricted"
        AuthType Basic
        AuthUserFile /etc/awstats/awstats.htpasswd

        <Files awstats.pl>
                Require valid-user
        </Files>
        Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
    </Directory>

    RewriteEngine On

#RewriteRules for myoldsite.com, [URL unfurl="true"]www.myoldsite.com,[/URL] and mysite.com
    RewriteCond %{HTTP_HOST} ^myoldsite\.com [OR]
    RewriteCond %{HTTP_HOST} ^mysite\.com [OR]
    RewriteCond %{HTTP_HOST} ^[URL unfurl="true"]www\.myoldsite\.com[/URL]
    RewriteRule ^(.*)$ [URL unfurl="true"]http://www.mysite.com/$1[/URL] [R=301,L]
</VirtualHost>

Contents of .htaccess:
Code:
#
# Apache/PHP/Drupal settings:
#

# Protect files and directories from prying eyes.
<FilesMatch "(\.(engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)|code-style\.pl|Entries.*|Repository|Root|Tag|Template)$">
  Order allow,deny
</FilesMatch>

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Follow symbolic links in this directory.
Options +FollowSymLinks

# Customized error messages.
ErrorDocument 404 /index.php

# Set the default handler.
DirectoryIndex index.php

# Override PHP settings. More in sites/default/settings.php
# but the following cannot be changed at runtime.

# PHP 4, Apache 1.
<IfModule mod_php4.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

# PHP 4, Apache 2.
<IfModule sapi_apache2.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value magic_quotes_gpc                0
  php_value register_globals                0
  php_value session.auto_start              0
</IfModule>

                                                              23,1          23%
# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On
  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600
  # Do not cache dynamically generated pages.
  ExpiresByType text/html A1
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # If your site can be accessed both with and without the prefix www. you
  # can use one of the following settings to force user to use only one option:
  #
  # If you want the site to be accessed WITH the www. only, adapt and
  # uncomment the following:
  # RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
  # RewriteRule .* [URL unfurl="true"]http://www.example.com/[/URL] [L,R=301]
  #
  # If you want the site to be accessed only WITHOUT the www. prefix, adapt
  # and uncomment the following:
  # RewriteCond %{HTTP_HOST} ^[URL unfurl="true"]www\.example\.com$[/URL] [NC]
  # RewriteRule .* [URL unfurl="true"]http://example.com/[/URL] [L,R=301]

  # Modify the RewriteBase if you are using Drupal in a subdirectory and
  # the rewrite rules are not working properly.
  #RewriteBase /drupal

  # Rewrite old-style URLs of the form 'node.php?id=x'.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^id=([^&]+)$
  #RewriteRule node.php index.php?q=node/view/%1 [L]

  # Rewrite old-style URLs of the form 'module.php?mod=x'.
  #RewriteCond %{REQUEST_FILENAME} !-f
  #RewriteCond %{REQUEST_FILENAME} !-d
  #RewriteCond %{QUERY_STRING} ^mod=([^&]+)$
  #RewriteRule module.php index.php?q=%1 [L]

  # Rewrite current-style URLs of the form 'index.php?q=x'.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>

# $Id: .htaccess,v 1.81 2007/01/09 09:27:10 dries Exp $
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top