• Here’s my situation:

    1. I want to have a custom page on my wordpress instillation at /checkout.

    2. I added a “checkout” folder in my domain.

    3. I added index.php in the checkout folder.

    4. I want to be able to go to /checkout/step1, /checkout/step2..

    5. WordPress sees that page as “not existing”, even though it’s technically not a WordPress post/category – it’s a subfolder in the Home/www directory.

    Does anyone know how to tell WordPress to ignore the fact that /checkout/XXX does not exist?

    I’m sure it’s a .htaccess issue, but can someone lend me hand?

    My first step was to copy my existing .htacess file to /checkout. Here is what is currently in /checkout/.htaccess:
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>

    Thanks for the help in advance

Viewing 3 replies - 1 through 3 (of 3 total)
  • The main .htaccess in WP root folder could look like this:

    # BEGIN Alexander
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^checkout/step1$ /checkout/step1.php [QSA,L]
    RewriteRule ^checkout/step2$ /checkout/step2.php [QSA,L]
    RewriteRule ^checkout/step3$ /checkout/step3.php [QSA,L]
    </IfModule>
    # END Alexander
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    Your own block ensures, that the urls with checkout/step1 will be translated and directed to checkout/step1.php and delivered.
    Keep in mind, that you will normally not be able to access at this php paged workpress code as long as you not launch the loader from wp.

    You could also direct all steps to one php file by giving as param like this, but please sanitize the incomming param value carefully:

    # BEGIN Alexander
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^checkout/(.*)$ /checkout.php?step=$1 [QSA,L]
    </IfModule>
    # END Alexander
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    where you now get at the checkout.php as $_GET[‘step’] the given step(s) like “step1” but there could also arrive some bad things, check it!

    Thread Starter alexanderacook

    (@alexanderacook)

    Wow! Thanks for the super detailed feedback.

    I’ll give it a try now.

    Thanks!!!

    Thread Starter alexanderacook

    (@alexanderacook)

    Thanks – that worked!

    I have a similarly related question –

    Let’s say I have a wordpress page, e.g. mysite.com/storefinder.

    I’d like to be able to have urls like /storefinder/united-states/state/city/etc/etc.

    How do I overwrite the WordPress 404 errors for this situation? I have a page setup called storefinder, and in that page I have some PHP code – but if I go to /storefinder/anything – WordPress throws a 404 error.

    Any ideas?

    Thanks again @codestyling for answering my first question.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘.htaccess help – adding a custom directory to www/home directory, override WP’ is closed to new replies.