Forum Moderators: phranque
Now here's the problem. I have clean links enabled on my site's software (drupal) and I want to keep it on. It makes the site great for search engines and much easier for users to understand. However, I have some directories on my site that are not a part of drupal, but are still on the main site. I want to allow those directories to go through normally while letting druapl keep it's rewrite rules.
I have no clue about rewrite rules as druapl automatically created the .htaccess file for me.
Any help is greatly appreciated!
Keith McDermott
[edited by: jdMorgan at 10:08 pm (utc) on Mar. 22, 2005]
[edit reason] No sigs, please. [/edit]
Welcome to WebmasterWorld!
There are several ways to do this.
The most foolproof way to do it would be to bypass the drupal mod_rewrite directives for those directories. For example to bypass the rules for the subdirectory "/no_rewrite/mystuff/dir1/" you would add the code:
RewriteRule ^no_rewrite/mystuff/dir1 - [L]
This says, "If the requested local URL-path starts with 'no_rewrite/mystuff/dir1/', then don't change the URL, and stop rewriting."
Jim
OK - I added the lines but it still redirects me to the main page. Maybe there's something else in my htaccess? Below is the whole thing. Let me know if you see something or if the code you told me to add is wrong - it is relative to the web root and not the server root right?
.htaccess file contents:
---------------------------------------------
#
# Apache/PHP/site settings:
#
# Protect files and directories from prying eyes:
<Files ~ "(\.(conf¦inc¦module¦pl¦sh¦sql¦theme¦engine¦xtmpl)¦Entries¦Repositories¦Root¦scripts¦updates)$">
order deny,allow
deny from all
</Files>
# Set some options
Options -Indexes
Options +FollowSymLinks
# Customized server error messages:
ErrorDocument 404 /index.php
# Set the default handler to index.php:
DirectoryIndex index.php
# Overload PHP variables:
<IfModule mod_php4.c>
# If you are using Apache 2, you have to use <IfModule sapi_apache2.c>
# instead of <IfModule mod_php4.c>.
php_value register_globals 0
php_value track_vars 1
php_value short_open_tag 1
php_value magic_quotes_gpc 0
php_value magic_quotes_runtime 0
php_value magic_quotes_sybase 0
php_value arg_separator.output "&"
php_value session.cache_expire 200000
php_value session.gc_maxlifetime 200000
php_value session.cookie_lifetime 2000000
php_value session.auto_start 0
php_value session.save_handler user
php_value session.cache_limiter none
php_value allow_call_time_pass_reference On
</IfModule>
# Various rewrite rules
<IfModule mod_rewrite.c>
RewriteEngine on
# 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]
# Disable rewrite for specific directories
RewriteRule ^Keith - [L]
RewriteRule ^PNC - [L]
RewriteRule ^SOL - [L]
RewriteRule ^jake - [L]
RewriteRule ^errors - [L]
RewriteRule ^webalizer - [L]
RewriteRule ^modlogan - [L]
RewriteRule ^people - [L]
RewriteRule ^software - [L]
RewriteRule ^swg - [L]
RewriteRule ^teri - [L]
RewriteRule ^test - [L]
# Rewrite 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.58 2004/10/09 20:41:49 dries Exp $
Anyway, I tried moving around the new stuff to various parts of .htaccess, but it still keeps redirecting me to the main page. The various changes I tried were to move my custom stuff to the very beginning of htaccess, then to the beginning of the mod_rewrite section and so on. In all changes it keeps reverting back to the root. The only thing I can think of is that the server cache's the .htaccess for a time? If not, then I'm still stuck.
Try going into one or more of your subdirectories, such as "/jake", and adding RewriteOptions inherit to .htaccess in that subdirectory. Then test those subdirectories. This will force Apache to process your Web-root-level .htaccess before processing the subdirectory.
Whenever you work on any server-side code that modifies the content returned by a given URL, or that modifies access controls, you'll need to flush your browser cache, and any other intervening caches (such as your local caching proxy if you run one). Otherwise, your browser will return its local copy of the content you requested, and the request will never be sent to your server. (I'm assuming here that you have not marked the content as non-cacheable on the server).
Jim
Anyway, thanks for your help with all this and if you have any other ideas I'd be happy to try anything so long as it doesn't break the main site! :-)
# Rewrite URLs of the form 'index.php?q=x':
RewriteCond %{REQUEST_FILENAME}!-f
RewriteCond %{REQUEST_FILENAME}!-d
RewriteCond %{THE_REQUEST}!/subd1
RewriteCond %{THE_REQUEST}!/subd2
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
and make another htaccess in the directories with a DirectoryIndex