Drupal 8.5.4 all links give 404 Not Found - drupal-8

I am using Ubuntu 18.04 server and Drupal 8.5.4. The installation was successful.I can login and my home page is displayed . But any other url on the page gives error. One such error is
*
Not Found
The requested URL /drupal-8.5.4/admin/content was not found on this server.
*
Thank you all in anticipation.
These ar all the details I could think of adding. Please let me know if anything else will be required
My .htaccess file is as follows
#
# Apache/PHP/Drupal settings:
#
# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|install|make|module|profile|po|sh|.*sql|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock))$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$">
<IfModule mod_authz_core.c>
Require all denied
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
</IfModule>
</FilesMatch>
# Don't show directory listings for URLs which map to a directory.
Options -Indexes
# Set the default handler.
DirectoryIndex index.php index.html index.htm
# Add correct encoding for SVGZ.
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
# Most of the following PHP settings cannot be changed at runtime. See
# sites/default/default.settings.php and
# Drupal\Core\DrupalKernel::bootEnvironment() for settings that can be
# changed at runtime.
# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
php_value assert.active 0
php_flag session.auto_start off
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_flag mbstring.encoding_translation off
# PHP 5.6 has deprecated $HTTP_RAW_POST_DATA and produces warnings if this is
# not set.
php_value always_populate_raw_post_data -1
</IfModule>
# 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
<FilesMatch \.php$>
# Do not allow PHP scripts to be cached unless they explicitly send cache
# headers themselves. Otherwise all scripts would have to overwrite the
# headers set by mod_expires if they want another caching behavior. This may
# fail if an error occurs early in the bootstrap process, and it may cause
# problems if a non-Drupal PHP file is installed in a subdirectory.
ExpiresActive Off
</FilesMatch>
</IfModule>
# Set a fallback resource if mod_rewrite is not enabled. This allows Drupal to
# work without clean URLs. This requires Apache version >= 2.2.16. If Drupal is
# not accessed by the top level URL (i.e.: http://example.com/drupal/ instead of
# http://example.com/), the path to index.php will need to be adjusted.
<IfModule !mod_rewrite.c>
FallbackResource /index.php
</IfModule>
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
# Set "protossl" to "s" if we were accessed via https://. This is used later
# if you enable "www." stripping or enforcement, in order to ensure that
# you don't bounce between http and https.
RewriteRule ^ - [E=protossl]
RewriteCond %{HTTPS} on
RewriteRule ^ - [E=protossl:s]
# Make sure Authorization HTTP header is available to PHP
# even when running as CGI or FastCGI.
RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Block access to "hidden" directories whose names begin with a period. This
# includes directories used by version control systems such as Subversion or
# Git to store control files. Files whose names begin with a period, as well
# as the control files used by CVS, are protected by the FilesMatch directive
# above.
#
# NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is
# not possible to block access to entire directories from .htaccess because
# <DirectoryMatch> is not allowed here.
#
# If you do not have mod_rewrite installed, you should remove these
# directories from your webroot or otherwise protect them from being
# downloaded.
RewriteRule "/\.|^\.(?!well-known/)" - [F]
# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/foo will be redirected to http://www.example.com/foo)
# uncomment the following:
# RewriteCond %{HTTP_HOST} .
# RewriteCond %{HTTP_HOST} !^www\. [NC]
# RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/foo will be redirected to http://example.com/foo)
# uncomment the following:
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /
# Redirect common PHP files to their new locations.
RewriteCond %{REQUEST_URI} ^(.*)?/(install.php) [OR]
RewriteCond %{REQUEST_URI} ^(.*)?/(rebuild.php)
RewriteCond %{REQUEST_URI} !core
RewriteRule ^ %1/core/%2 [L,QSA,R=301]
# Rewrite install.php during installation to see if mod_rewrite is working
RewriteRule ^core/install.php core/install.php?rewrite=ok [QSA,L]
# Pass all requests not referring directly to files in the filesystem to
# index.php.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
# For security reasons, deny access to other PHP files on public sites.
# Note: The following URI conditions are not anchored at the start (^),
# because Drupal may be located in a subdirectory. To further improve
# security, you can replace '!/' with '!^/'.
# Allow access to PHP files in /core (like authorize.php or install.php):
RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
# Allow access to test-specific PHP files:
RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php
# Allow access to Statistics module's custom front controller.
# Copy and adapt this rule to directly execute PHP files in contributed or
# custom modules or to run another PHP application in the same directory.
RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$
# Deny access to any other PHP files that do not match the rules above.
# Specifically, disallow autoload.php from being served directly.
RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]
# Rules to correctly serve gzip compressed CSS and JS files.
# Requires both mod_rewrite and mod_headers to be enabled.
<IfModule mod_headers.c>
# Serve gzip compressed CSS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*)\.css $1\.css\.gz [QSA]
# Serve gzip compressed JS files if they exist and the client accepts gzip.
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{REQUEST_FILENAME}\.gz -s
RewriteRule ^(.*)\.js $1\.js\.gz [QSA]
# Serve correct content types, and prevent mod_deflate double gzip.
RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]
<FilesMatch "(\.js\.gz|\.css\.gz)$">
# Serve correct encoding type.
Header set Content-Encoding gzip
# Force proxies to cache gzipped & non-gzipped css/js files separately.
Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>
</IfModule>
# Various header fixes.
<IfModule mod_headers.c>
# Disable content sniffing, since it's an attack vector.
Header always set X-Content-Type-Options nosniff
# Disable Proxy header, since it's an attack vector.
RequestHeader unset Proxy
</IfModule>
# RewriteBase /~name

Now, Need to activate mod_rewrite:
sudo a2enmod rewrite
This will activate the module or alert you that the module is already in effect. To put these changes into effect, restart Apache:
sudo service apache2 restart

I changed
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
to
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
in /etc/apache2/apach2.conf , restarted Apache with service apache2 restart

There are two things
1: Ensure that mod_rewrite is enabled
To check this create a file called phpinfo.php in the root of your site. This file should be accessible from a web browser and contain this code:
phpinfo();
Navigate to phpinfo.php in a browser like this: http://www.example.com/phpinfo.php
On that page, look for a section called "Loaded Modules" and check that mod_rewrite is included. If not, mod_rewrite is not being loaded by apache and will need to be enabled. To enable this mode just write the following command in terminal and restart the apache
sudo a2enmod rewrite
2:Ensure that Drupal's .htaccess file is being used
Once it's been confirmed that mod_rewrite is enabled, double check that Drupal's .htaccess file is in the site's root, and that it is working. Confirm that .htaccess is enabled by temporarily replacing Drupal's .htaccess file. Make a backup of the existing .htaccess and create one like this
DirectoryIndex phpinfo.php
Now try the site URL without specifing a page or file in a web browser: http://www.example.com/. If you see PHP's phpinfo dump, the .htaccess file worked and you can restore the old one. If not, the server may not be allowing .htaccess overrides for your site.To allow this edit you virtual hosting file or apache2.conf file. For apache2.conf file change
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
to
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Restart the apache and hopefully site works well

If you are installing drupal with composer run the composer create-project command at a path where sudo permission is not required and then move the drupal project directory to the apache web server's Document root (i.e /var/www/html which is the default one)
Reason for doing this:
When you run the composer create-project command with sudo, the .htaccess file is not created inside the project directory which causes disabling of all urls except the home page of drupal site
This was a problem due to .htaccess which got solve but if it's because of someother reason check out the documentation or the Drupal forum

Related

Ignore subfolders of URI in .htaccess

I have an app where you can send a link to content. The link is build like this:
domain.com/share/param1/param2/param3
The app is opened if the user has the app installed, otherwise it will open the website. For those who have not the app installed I got a webpage at domain.com/share where links to download the app are placed. The problem is that if you call / share/.../.../... you don't get redirected to /share.
I want to redirect everything with /share/... beginning to /share
I'm running Wordpress on an Apache
What I tried:
RewriteEnginge On
#1
RewriteRule ^share/.*$ share
#2
RewriteRule ^share/(.*)$ share
#3
RewriteRule ^share\/(.*)$ share
#4
RewriteRule share/.* share
#5 this is to exclude an error to Regex
RewriteRule share/test share
The rest of the .htaccess which (hopefully) doesn't have an impact:
# BEGIN Thunermay (Admin)
# set apple-app-site-association as application/json for Apple's crawler
<Files "apple-app-site-association">
Header set Content-type 'application/json'
</Files>
# ensure https
RewriteEngine On
# redirect all /share/anything links to /share
# Here was I trying to get it to work #
RewriteCond %{HTTPS} !on
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301]
# END Thunermay
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
# php -- BEGIN cPanel-generated handler, do not edit
# Set the “ea-php72” package as the default “PHP” programming language.
<IfModule mime_module>
AddHandler application/x-httpd-ea-php74 .php .php7 .phtml
</IfModule>
# php -- END cPanel-generated handler, do not edit
Thanks in advance!
The problem was, as #Cbroe stated, that I didn't redirect to the page but would only internally redirect, where the problem is, that this site does not exist. The solution was:
RewriteRule /share/.+ share [R,L]
The + is to have at least one character because otherwise it ended in an infinite loop, the R is to redirect it and not only show it in the URI and the L is for that it is the last rule and Wordpress does not catch it and point to the landing page.
The slight problem remaining is that my https redirect does not work anymore IF I have a share link and use http which my URI-generator does not, so it should not be an problem.

Block all user-agents by htaccess except one

I have a htaccess rewrite rule code which works on Apache but not on litespeed.
<Files "bg.js">
SetEnvIfNoCase User-Agent .*autoit.* search_robot
Order Deny,Allow
Deny from All
Allow from env=search_robot
</Files>
I want to block all useragents except those that are a case insensitive match to autoit.
How do I get the rewrite rule to work on litespeed?
Unfortunately, LiteSpeed does not support SetEnvIf* directives in .htaccess files. As an alternative, you'll need to use mod_rewrite:
RewriteEngine On
# Check that the request is for /bg.js
RewriteCond %{REQUEST_URI} ^/bg.js
# Check that the request matches an existing file
RewriteCond %{REQUEST_FILENAME} -f
# Check that the user agent does not contain autoit
RewriteCond %{HTTP_USER_AGENT} !autoit
# If all conditions above are met, then deny access to this request
RewriteRule ^ - [F,L]

Error after activating SEO Settings in Joomla 2.5

I am using Shape5 Corporate Response template for Joomla 2.5
In order for me to activate the SEO freidnly website I had to:
1- Change htaccess.txt to .htaccess
2- In global configuration change Search Engine Friendly URLs from No to Yes
3- Change Use URL rewriting From No to Yes
after that the template runs but the menu that I created does not work and when I click on it, it says:
Not Found
The requested URL /contact was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to
use an ErrorDocument to handle the request.
I already did this test :
http://docs.joomla.org/How_to_check_if_mod_rewrite_is_enabled_on_your_server
and my mod rewrite is enabled.
also I edited "# RewriteBase /" to "RewriteBase /" in htaccess but no luck.
here is my htaccess:
> # #package Joomla
> # #copyright Copyright (C) 2005 - 2012 Open Source Matters. All rights reserved.
> # #license GNU General Public License version 2 or later; see LICENSE.txt
> ##
>
> ##
> # READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE!
> #
> # The line just below this section: 'Options +FollowSymLinks' may cause problems
> # with some server configurations. It is required for use of mod_rewrite, but may already
> # be set by your server administrator in a way that dissallows changing it in
> # your .htaccess file. If using it causes your server to error out, comment it out (add # to
> # beginning of line), reload your site in your browser and test your sef url's. If they work,
> # it has been set by your server administrator and you do not need it set here.
> ##
>
> ## Can be commented out if causes errors, see notes above. Options +FollowSymLinks
>
> ## Mod_rewrite in use.
>
> RewriteEngine On
>
> ## Begin - Rewrite rules to block out some common exploits.
> # If you experience problems on your site block out the operations listed below
> # This attempts to block the most common type of exploit `attempts` to Joomla!
> #
> # Block out any script trying to base64_encode data within the URL. RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
> # Block out any script that includes a <script> tag in URL. RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
> # Block out any script trying to set a PHP GLOBALS variable via URL. RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
> # Block out any script trying to modify a _REQUEST variable via URL. RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
> # Return 403 Forbidden header and show the content of the root homepage RewriteRule .* index.php [F]
> #
> ## End - Rewrite rules to block out some common exploits.
>
> ## Begin - Custom redirects
> #
> # If you need to redirect some pages, or set a canonical non-www to
> # www redirect (or vice versa), place that code here. Ensure those
> # redirects use the correct RewriteRule syntax and the [R=301,L] flags.
> #
> ## End - Custom redirects
>
> ##
> # Uncomment following line if your webserver's URL
> # is not directly related to physical file paths.
> # Update Your Joomla! Directory (just / for root).
> ##
>
> # RewriteBase /
>
> ## Begin - Joomla! core SEF Section.
> # RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
> #
> # If the requested path and file is not /index.php and the request
> # has not already been internally rewritten to the index.php script RewriteCond %{REQUEST_URI} ^GET
> # and the request is for something within the component folder,
> # or for the site root, or for an extensionless URL, or the
> # requested URL ends with one of the listed extensions RewriteCond %{REQUEST_URI} /component/|(/[^.]*|\.(php|html?|feed|pdf|vcf|raw))$
> [NC]
> # and the requested path and file doesn't directly match a physical file RewriteCond %{REQUEST_FILENAME} !-f
> # and the requested path and file doesn't directly match a physical folder RewriteCond %{REQUEST_FILENAME} !-d
> # internally rewrite the request to the index.php script RewriteRule .* index.php [L]
> #
> ## End - Joomla! core SEF Section.
How can I fix this issue ?
I found the solution, just add replace this code in your .htaccess file:
AddHandler x-httpd-php5 .php
AddHandler x-httpd-php .php4
##
# #version $Id: htaccess.txt 14401 2010-01-26 14:10:00Z louis $
# #package Joomla
# #copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
# #license http://www.gnu.org/copyleft/gpl.html GNU/GPL
# Joomla! is Free Software
##
#####################################################
# READ THIS COMPLETELY IF YOU CHOOSE TO USE THIS FILE
#
# The line just below this section: 'Options +FollowSymLinks' may cause problems
# with some server configurations. It is required for use of mod_rewrite, but may already
# be set by your server administrator in a way that dissallows changing it in
# your .htaccess file. If using it causes your server to error out, comment it out (add # to
# beginning of line), reload your site in your browser and test your sef url's. If they work,
# it has been set by your server administrator and you do not need it set here.
#
#####################################################
## Can be commented out if causes errors, see notes above.
Options +FollowSymLinks
#
# mod_rewrite in use
RewriteEngine On
########## Begin - Rewrite rules to block out some common exploits
## If you experience problems on your site block out the operations listed below
## This attempts to block the most common type of exploit `attempts` to Joomla!
#
## Deny access to extension xml files (uncomment out to activate)
#<Files ~ "\.xml$">
#Order allow,deny
#Deny from all
#Satisfy all
#</Files>
## End of deny access to extension xml files
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
RewriteRule ^(.*)$ index.php [F,L]
#
########## End - Rewrite rules to block out some common exploits
# Uncomment following line if your webserver's URL
# is not directly related to physical file paths.
# Update Your Joomla! Directory (just / for root)
RewriteBase /
########## Begin - Joomla! core SEF Section
#
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/index.php
RewriteCond %{REQUEST_URI} (/|\.php|\.html|\.htm|\.feed|\.pdf|\.raw|/[^.]*)$ [NC]
RewriteRule (.*) index.php
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]
#
########## End - Joomla! core SEF Section

Running a django project in a subdirectory of a site already running Drupal

This problem has been bugging me for the last week or so and now I am coming up on a deadline. I have a site on a Media Temple DV server that is running Drupal in the webroot (servername.org). I am adding a django site and I would like it to be located at the url servername.org/myproject. I have build the project (in a directory not in the webroot) and it is working fine when I run it with the django dev server but I cannot get apache configured to run my django site.
I followed this tutorial http://how.4cpus.com/installing-django-on-mt-media-temple-dv-35-server-with-mod_python/
to do the initial setup and configured vhost..conf as explained there. But the Drupal generated .htaccess file keeps grabbing my url and returning a 404 error.
The only work around I have so far is that if I create a subdirectory in webroot called httpdocs/myproject and then goto the url servername.org/myproject it works. But as soon I try to go to any subfolder of myproject (e.g. servername/myproject/login) I get the 404 error again.
Any help here? I know it must be an easy one or two line apache configuration thing but I can't figure it out and I'm running out of ideas.
Here is a snippet from the vhost.conf file:
<Location "/myproject/">
SetHandler python-program
PythonPath "['/var/www/vhosts/servename.org/']+sys.path"
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE myproject.settings
PythonInterpreter myproject
</Location>
And here is the Drupal .htaccess file in webroot (notice the rewirte rule I put in near the end that doesn't appear to do anything):
#
# Apache/PHP/Drupal settings:
#
# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|info|install|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl|svn-base)$|^(code-style\.pl|Entries.*|Repository|Root|Tag|Template|all-wcprops|entries|format)$">
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
# Make Drupal handle any 404 errors.
ErrorDocument 404 /index.php
# Force simple error message for requests for non-existent favicon.ico.
<Files favicon.ico>
# There is no end quote below, for compatibility with Apache 1.3.
ErrorDocument 404 "The requested file favicon.ico was not found.
</Files>
# 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
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 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
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 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
php_value mbstring.http_input pass
php_value mbstring.http_output pass
php_value mbstring.encoding_translation 0
</IfModule>
# 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
<FilesMatch \.php$>
# Do not allow PHP scripts to be cached unless they explicitly send cache
# headers themselves. Otherwise all scripts would have to overwrite the
# headers set by mod_expires if they want another caching behavior. This may
# fail if an error occurs early in the bootstrap process, and it may cause
# problems if a non-Drupal PHP file is installed in a subdirectory.
ExpiresActive Off
</FilesMatch>
</IfModule>
# Various rewrite rules.
<IfModule mod_rewrite.c>
RewriteEngine on
# If your site can be accessed both with and without the 'www.' prefix, you
# can use one of the following settings to redirect users to your preferred
# URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
#
# To redirect all users to access the site WITH the 'www.' prefix,
# (http://example.com/... will be redirected to http://www.example.com/...)
# adapt and uncomment the following:
# RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
# RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
#
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment and adapt the following:
# RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC]
# RewriteRule ^(.*)$ http://example.com/$1 [L,R=301]
# Modify the RewriteBase if you are using Drupal in a subdirectory or in a
# VirtualDocumentRoot and the rewrite rules are not working properly.
# For example if your site is at http://example.com/drupal uncomment and
# modify the following line:
# RewriteBase /drupal
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /
# Added by Wil Black Oct. 7, 2010
RewriteCond %{REQUEST_URI} "/myproject/"
RewriteRule (.*) $1 [L]
# Rewrite URLs of the form 'x' to the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
</IfModule>
# $Id: .htaccess,v 1.90.2.4 2009/12/07 12:00:40 goba Exp $
[1]: http://how.4cpus.com/installing-django-on-mt-media-temple-dv-35-server-with-mod_python/
The problem is probably that drupal grabs URL's that are in the form domain/path1/path2 and converts them to domain?q=path1/path2, and thus is probably grabbing everything that is trying to get to Django, and turning it into a drupal call. So my guess is that what you need to do is add a new rewrite condition to drupal's htaccess telling it to ignore anything targeted at the Django subdirectory. I haven't done this before, but I would guess you want something like this:
RewriteCond %{REQUEST_URI} !=/Django_subdirectory
This should go along with all of the other rewrite conditions in that file.

static site apache and dynamic/member site django

I have a site for static content, accessible to all that runs on apache. As an adjunct to that, there is a members site that runs on django. I haven't had any issue 'sharing' my .css and making both sides equivalent in appearance, but what I can't quite seem to grok is getting my django site to be django password protected (with the additional caveat that all member material, from the login forward, goes through 443).
I can serve all the pages, I have tried to use mod_rewrite as follows:
<Directory /Library/Webserver/Documents>
.
.
.
</Directory>
WSGIScriptAlias /members /usr/local/django/mysite/apache/django.wsgi
<Directory /members>
RewriteCond %{HTTPS} off
RewriteRule (.*) https://{HTTP_HOST}%{REQUEST_URI} [L]
.
.
</Directory>
I have tried every one of a thousand different items in the '/members location above, nothing seems to hit (and yes, RewriteEngine On is included - I can watch the debug come out).
Try:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
You should be redirecting back to same host the request was made against, not necessarily the actual web server host.
I also don't believe there is a %{URI} variable in mod_rewrite. Supposed to use %{REQUEST_URI}.
EDIT 1
As per comments, should be:
<Location /members>
RewriteCond %{HTTPS} off
RewriteRule (.*) https://{HTTP_HOST}%{REQUEST_URI} [L]
.
.
</Location>
or:
<Directory /usr/local/django/mysite/apache>
RewriteCond %{HTTPS} off
RewriteRule (.*) https://{HTTP_HOST}%{REQUEST_URI} [L]
.
.
</Directory>
So, Location is for URL and Directory is for file system directory.