0

I got this from this page: https://developers.google.com/commerce/wallet/online/quickstart-php

I am wondering how to re-write it to work in a subdirectory.

like /subdirectory/index.php

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L,NC,QSA]
  • Put it in the subdirectory :) – hank Aug 29 '13 at 03:11
  • 1
    Study the [mod_rewrite manual](http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html) and specifically read up on [what RewriteBase does](http://stackoverflow.com/questions/704102/how-does-rewritebase-work-in-htaccess). – mario Aug 29 '13 at 03:13

1 Answers1

1

Here's what you need to do:

  1. Change the RewriteBase to the name of your subdirectory
  2. Remove the leading slash from the /index.php
  3. Place the rules in an htaccess file in your subdirectory.

So say your subdirectory is called /subdir and you have http://domain.com/subdir/index.php, you'd have this:

RewriteEngine On
RewriteBase /subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L,NC,QSA]
Jon Lin
  • 142,182
  • 29
  • 220
  • 220