Barchie
Barchie

Reputation: 37

mod rewrite for all requests after a directory

I am looking to do a rewrite for all requests after a directory in a url, but cant for the life of me figure out how to do it.

Essentially looking for:

url.com/directory/anything/after/the/directory/

So if any requests com to url.com/directory/ regardless of what comes after it is redirected back to the index that was before the directory (ie. url.com)

I tried with a regex pattern: /forex/.?(.*)

But i'm really not getting anywhere.

Can anybody kick me in the right direction. I was essentially going for:

RewriteRule \/forex\/.?(.*) inxe.php

This didnt work though.

Appreciate all responses, thanks!

Upvotes: 1

Views: 33

Answers (2)

Rohit
Rohit

Reputation: 1812

Before any rule make sure you write RewriteEngine on

Upvotes: 1

Amit Verma
Amit Verma

Reputation: 41219

Try :

RewriteRule ^/?dir/((?!index).+)$ /index.php [NC,L,QSA]

This will redirect

  • /dir/foo/bar (excluding the directory index file)

to

  • /index.php

Upvotes: 0

Related Questions