views:

614

answers:

4

I'm new to mod_rewrite and have just been going by trial and error so far, I'd like to redirect all URL requests to /drupal-6.13/ and hide the /drupal-6.13/, but if the URL is www.site.com/wiki not to rewrite anything. I'm also using the pathauto mod in drupal to create /content/title links for story content. I think it's the last section in the top and bottom htaccess that's rewriting the url, because www.iamthelaw.net/wiki gets rewritten as http://www.iamthelaw.net/wiki/?q=wiki, but if I try removing them the admin links and content links no longer work. Is there anything I can add without taking out what's currently there to override just for the /wiki/ requests?

here's the htacess in the top level:

Options -Indexes
RewriteEngine on
Options +FollowSymLinks

#site
RewriteCond %{HTTP_HOST} ^www\.iamthelaw\.net$ [NC]
RewriteCond %{REQUEST_URI} !^/drupal-6.13
RewriteRule ^$ /drupal-6.13/index.php [L]


#files
RewriteCond %{HTTP_HOST} ^www\.iamthelaw\.net$ [NC]
RewriteCond %{REQUEST_URI} ^.*\.(jpg|jpeg|gif|png|css|js|pl|txt)$
RewriteCond %{REQUEST_URI} !^/drupal-6.13/
RewriteRule ^(.*)$ /drupal-6.13/$1 [L,QSA]

#url 's
RewriteCond %{HTTP_HOST} ^www\.iamthelaw\.net$ [NC]
RewriteCond %{REQUEST_URI} !^/drupal-6.13
RewriteRule ^(.*)$ /drupal-6.13/index.php?q=$1 [L,QSA]

and in the rewrite section of the htacess in the subfolder /drupal-6.13/:

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

RewriteBase /drupal-6.13


# 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 ^(.*)$ /drupal-6.13/index.php?q=$1 [L,QSA]
</IfModule>
A: 

Put the rewrite rule for /wiki earlier in the file and make sure it has a L as part of the modifiers (most likely it'd be [L,QSA]) so that it is the Last rule processed for matching URLs, thus the later rewrites won't affect it.

Amber
Thanks for the help, I tried adding: #wiki RewriteCond %{HTTP_HOST} ^www\.iamthelaw\.net\wiki$ [NC] RewriteCond %{REQUEST_URI} !^/wiki RewriteRule ^(.*)$ /wiki [L,QSA]to the top of the first htaccess and above the RewriteBase line in the second htaccess, but I still get www.iamthelaw.net/wiki redirected to http://www.iamthelaw.net/wiki/?q=wiki
A: 

As I think Dav was saying, you make a rule for /wiki first, with [L] so further rules are ignored for /wiki. followed by your rule for other suff

RewriteRule ^wiki /wiki  [L]
RewriteRule ^.* /notwiki

I hope you can adapt this to your situation

JasonWoof
A: 

I think you just need two rules:

RewriteCond %{THE_REQUEST} ^GET\ /drupal-6\.13
RewriteRule ^drupal-6\.13($|/.*) 
RewriteRule !^wiki($|/) drupal-6.13/index.php [L]

These remove /drupal-6.13 from any request, that’s URL path starts with /drupal-6.13/, and rewrite any request, that’s URL path does not start with /wiki/, internally to /drupal-6.13/index.php.

Gumbo
A: 

I've tried this locally and it seems to work. It's for your root .htaccess file:


RewriteEngine on

# Leave the wiki calls alone
RewriteCond %{REQUEST_URI} ^wiki.*$
RewriteRule ^.*$ - [L]

# redirect everything else to the drupal directory. 
# the drupal .htaccess takes care of drupal-specific rewrites 
RewriteRule ^(.*)$ drupal-6.13/$1 [L]

And.. I don't think you need to RewriteBase in your drupal .htaccess file either, since all the urls are already being redirected to that folder.

Heather Gaye