Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

This link is pointing to my home directory. I want my users to see ~/home/prototype.php page when they come to my site. To achieve this, I have set following in my .htaccess file of that directory:

DirectoryIndex /home/prototype.php
# BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

There is a form which they need to fill and submit. The redirection of this form is set to www.imlovingdogs.com/index.php i.e. the main index.php page where wordpress starts loading other required files. But this www.imlovingdogs.com/index.php doesn't work! How can I achieve this kind of flow for my users?

share|improve this question

1 Answer 1

You can't set DirectoryIndex to prototype.php and expect everything else to work correctly. DirectoryIndex is not just a "landing page". A lot of requests go through that file.

I think you are making this more complicated than it needs to be.

  1. Put your code for prototype.php into a WordPress custom theme template file.
  2. Create a page that uses that file as the template
  3. Set that page as the static front page.

That lets you keep everything inside WordPress so you can do things like track whether a user is logged in and whether that user has filled out the form, and redirect away from the page if so. And you don't need to mess with rewriting at all.

There is another similar but mostly opposite approach.

Don't try to rewrite anything and let WordPress operate as normal. But use the template_redirect hook to check for user logged in status and to check if the user has filled in the form, and conditionally redirect to your form.

function redirect_to_prototypephp_wpse_101519() {
  $redir = true;
  if (is_user_logged_in()) {
    global $current_user;
    get_currentuserinfo();
    $filled_form = get_user_meta($user_id, '_prototype_form', true);
    if (true == $filled_form) {
      $redir = false;
    }
  }
  if (true === $redir) {
    wp_redirect('http://your-url/URL/to/prototype.php');
  }
}
add_action('template_redirect','redirect_to_prototypephp_wpse_101519');

This also allows you to use core WordPress functions but in a different way. The only additional component would be the need to set the _prototype_form usermeta key when the prototype.php form is submitted.

share|improve this answer
    
I am following your steps. I have set the front page as different page that has all my code from prototype.php. that works fine now. But now the issue is, when the default option was selected: "your latest posts", the page was different. However, I can't find the same page in the posts page dropdownlist under the settings. how can I find that? –  Yoda Jun 1 '13 at 19:03
    
I am not sure I understand you, but (I think) you need to create a page to serve as your post index page, then select that page from the dropdown at wp-admin->Settings->Reading –  s_ha_dum Jun 1 '13 at 19:08
    
ok let me try again. Before modifying anything, in the reading section, the front page display was set to "your latest posts". The page lets call it as "A", that I was able to see was different with topbar nav, slideshow, etc. Now, after changing the option to a static page, the front page is now changed. however, I am not able to find how to get the same page "A" in the posts page dropdownlist or just get the url of that page. –  Yoda Jun 1 '13 at 19:13
    
in other words: What file is the standard frontpage that lists all the posts? –  Yoda Jun 1 '13 at 19:21
    
Does your theme have a home.php or a front-page.php? –  s_ha_dum Jun 1 '13 at 19:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.