Rediredire to folder doesnot there


Consider I have a folder called docs

I want to redirect some of the request to ==> here word folder doesnot exist(which is $1) ==> here ppt folder doesnot exist(which is $1)

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

How this can be achieved? Please help…


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?



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 => directory word is not present but it is passed as the value for type.


(.*) 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.



Thanks, Its working fine