removing file extension in lighttpd.conf
Added by tibokistler@gmail.com about 12 years ago
Could someone please help me on this issue. I am using lighttpd and I have a problem removing the .php5 extension of my URLs. All the solutions I have found so far work if you are actually pointing to the URL without .php5 (if I go to mysite.com/page it actually shows the right page which is page.php5) and that is correct. I used this in lighttpd:
url.rewrite-once = ( "^(.*)/$" => "$1/" )
url.rewrite-if-not-file = ( "^([^?]*)(\?.*)?$" => "$1.php5$2" )
Now my problem is that all the links on my website which are going from page to page are written this way:
<a href="page.php5">
So whenever I click on a link I have mysite.com/page.php5 again. I wanted to spare all the time going through the website and changing the code on my links by doing something like that:
redirect mysite/page.php5 to mysite/page and then use the previous rewrite rule to actually display page.php5 even though only mysite/page shows in the URL. Is it possible and if it is how can I do it?
Thank you in advance for your help!
Replies (2)
RE: removing file extension in lighttpd.conf - Added by darix about 12 years ago
Fix your php code to emit links without the file ending? If you dont want the user to see the .php ... your output has to be cleaned. nothing lighty can do about it.
RE: removing file extension in lighttpd.conf - Added by tibokistler@gmail.com about 12 years ago
Hi thank you for your answer.
I know the way my code is is not ideal but after looking into it I have 1780 links including .php5 in 280 files and all of them should not be removed which is a huge amount of work to do I think.
Is it not possible to do in the conf file:
url.redirect = /link.php5 => /link
url.rewrite-once = ( "^(.*)/$" => "$1/" )
url.rewrite-if-not-file = ( "^([^?]*)(\?.*)?$" => "$1.php5$2" )
which basically will redirect the user to /link (and change the URL) and then as the URL is changed use the rewrite rule to display the right page.