I have a php-based system (called OJS) installed on my host. It uses SMARTY to create pages. I have pages with URLs such as: http://example.com/ojs/index.php/foo
I want to be able to type http://example.com/ojs/foo in the address bar, and .htaccess would add the index.php into the url, and execute the new full URL so that the index.php can generate the required page.
Now I use the following in the .htaccess file in ojs folder.
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [QSA,L]
</IfModule>
I have also tried so many other syntax and directives in the .htaccess. but non of them works. When I enter http://example.com/ojs/index.php/foo in address bar I get the page I want. When I enter http://example.com/ojs/foo (or any page not defined in ojs such as http://example.com/ojs/blahbla or http://example.com/ojs/index.php/blahblahbla) it shows the main page http://example.com/ojs/
I did a test and I guess Rewrite rule at least is doing something. I made a dummy php code in file index2.php (in ojs folder), which echos the superglobal values. For this test I modified the rewrite rule to include index2.php, and I get following results:
- for address: http://example.com/ojs/ (as desired) no URL rewriting is done, since I do not see the content of index2.php
- for address: http://example.com/ojs/anything I see the content of index2.php which echos the following values:
$_SERVER['HTTP_HOST']: example.com $_SERVER['REQUEST_URI']: /ojs/anything $_SERVER[SCRIPT_NAME]: /ojs/index2.php $_SERVER['PHP_SELF']: /ojs/index2.php $_SERVER['REQUEST_METHOD']: GET $_SERVER['PATH_INFO']: $_SERVER['ORIG_PATH_INFO']: /anything __FILE__: /home/user/public_html/ojs/index2.php
Can anyone think of why it works with index2.php and it does not work with index.php ?
My configuration if it helps:
PHP version 5.3.29, Apache version 2.2.29, host: Cpanel, Shared Linux host,
I do not have access to the main error log or Apache config file.
Thank you very much,