Rediredire to folder doesnot there

Dears,

Consider I have a folder called docs
mysite.com/docs/

I want to redirect some of the request to
mysite.com/docs/word/index.php ==> here word folder doesnot exist(which is $1)
mysite.com/docs/ppt/index.php ==> here ppt folder doesnot exist(which is $1)

RewriteRule ^(.*)/index.php$ /docs/$1/all-ind.php?=$1

How this can be achieved? Please help…

DQ,

I’m not sure I understand your “specification.” It appears to be “capture the subdirectory path (docs/word or docs/ppt) in the DocumentRoot and redirect to docs/subdirectory/all-ind.php with a query string which does not have a key.” It makes no sense to me!

Would you please provide a logical “specification” which includes examples of test URIs?

Regards,

DK

Thanks for the reply, now I am trying it from my localhost,

RewriteRule ^(.*)/index.php$ /docs/$1/all-ind.php?type=$1

where the attribute passed to type is word/ppt

but really there is no directory present as word or ppt, I want the output as

mysite.com/docs/word/index.php => directory word is not present but it is passed as the value for type.

DQ,

(.*) will not capture word or ppt (it’ll capture docs/word or docs/ppt) so that’s the first thing incorrect in your code.

The second thing is that you’re redirecting to docs/{word or ppt}/all-ind.php - what good does that do if the path does not exist?

To capture the subdirectory (word or ppt) of docs and redirect to docs/all-ind.php?type={word or ppt},

RewriteEngine on
RewriteRule ^docs/(word|ppt)/index\\.php$ docs/all-ind.php?type=$1 [R=301,L]
# remove the R=301 and comma if you do not want the redirection to show.

Regards,

DK

Thanks, Its working fine