Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use symlinks to remove .php extension -> raw .php file gets served

I have created a symlink (using ln -s index.php test) to my index.php to try and get a 'prettier' url without the .php extension. However, when I access https://myservername.com/test I get served the raw php file instead of the interpreted content.

I would like to avoid having to turn on mod_rewrite if possible since it will be for this one file only (I am using the CodeIgniter framework that does the url translation for the rest of the files).

Is there a way for apache to read the real destination file instead of the symlink to determine that it is a php script? Is there a better way of accomplishing this?

like image 213
Vertigo Avatar asked Jan 28 '26 03:01

Vertigo


1 Answers

I bet the problem is that Apache is only calling the PHP interpreter on files with a .php extension, and since your symlinks have no extension whatsoever they aren't interpreted.

Try using mod_rewrite instead, or try messing around with Apache directives, like FollowSymLinks - not sure if it applies here though. You don't want to enable the PHP parser for all files, that's for sure.

like image 106
Alix Axel Avatar answered Jan 29 '26 17:01

Alix Axel