views:

75

answers:

2

Hey all,

I'd like to do the following:

If a user gets to a url or types it in, and it is along the lines of any the following:

  • /path/path/path
  • /path
  • /path/path/

I would like htaccess to forward them to that url + /index.htm before triggering a 404. Also, I would like to ignore this rule for certain paths. Here is what I was trying and wasn't having success:

RewriteCond %{REQUEST_URI} !^(admin)
RewriteCond %{REQUEST_URI} !^(node)
RewriteRule ^/(.*)/$ $1/index.htm [L]

Here is how the app is outlined. It is actually a subdirectory within an application as the site is in transition at the moment.

ParentApp/
  /folder/
  /folder/
  /Drupal/
    /(new application here)
    /...
    /...
+1  A: 

The way you're rewriting looks like you're just trying to have 'index.htm' display as your index file for every directory, you're not actually redirecting anywhere. This can easily be imitated using DirectoryIndex index.htm.

If you trying to redirect to the root index file, here's an easier way to do it:

RewriteRule !^(admin/(.*)|node/(.*)) index.htm [L]

This is a rule similar to what I use for my website. Make sure you have RewriteEngine On.

animuson
I can't use the DirectoryIndex rule. The webapp is already using index.php for that.
Kevin
A DirectoryIndex rule in the .htaccess file should overrule any other rule that has been defined. You should add a small outline of how your public web folder is set up so we can help you further.
animuson
Okay... one sec
Kevin
Ok, so you're running one app in a folder inside another app, right? If you redefine the DirectoryIndex inside the .htaccess inside SubApp, it won't affect the DirectoryIndex of ParentApp, it will only affect files and folders inside that folder that it is in. It's like changing the rules only for that directory.
animuson
I just switched DirectoryIndex to index.htm and had no effect.
Kevin
A: 

Solved it. Was using the wrong regex character. Works now.

Kevin