SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Oct 2008
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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)


    Code:
    RewriteRule ^(.*)/index.php$ /docs/$1/all-ind.php?=$1
    How this can be achieved? Please help..

  2. #2
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  3. #3
    SitePoint Addict
    Join Date
    Oct 2008
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply, now I am trying it from my localhost,

    Code:
    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.

  4. #4
    Certified Ethical Hacker silver trophybronze trophy dklynn's Avatar
    Join Date
    Feb 2002
    Location
    Auckland
    Posts
    14,650
    Mentioned
    19 Post(s)
    Tagged
    3 Thread(s)
    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},
    Code:
    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
    David K. Lynn - Data Koncepts is a long-time WebHostingBuzz (US/UK)
    Client and (unpaid) WHB Ambassador
    mod_rewrite Tutorial Article (setup, config, test & write
    mod_rewrite regex w/sample code) and Code Generator

  5. #5
    SitePoint Addict
    Join Date
    Oct 2008
    Posts
    205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, Its working fine


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •