lighttpd rewrite-once issue - url-rewriting

Have a Python/fastcgi application that serves web pages (.html) and to download packages (.tar.gz). The problem is that lighttpd (on the host) is not finding the .js and .css files to display the web pages correctly. It seems to be an incorrect url.rewrite-once which is written as:
url.rewrite-once = (
"^/favicon.ico$" => "/assets/favicon.ico",
"^/assets/(.*)$" => "/assets/$1",
"^/(.*)$" => "/$1"
)
Is this correct?

Related

How to prevent webserver renderening default html page(like index.htm etc) if found in a directory

I wrote a ruby program which creates a webserver on 2000 port which is used for displaying directory structure present in linux node when accessed through browser using just HTTP URL.
require 'webrick'
include WEBrick
s = HTTPServer.new(
:Port => 2000,
:DocumentRoot => "/home/abc"
)
s.start()
I'm accessing throgh: http://10.x.x.x:2000/dir1/dir2...
Here i'm facing problem when "index.html or index.htm or index.jsp" present in any particular directory. Webserver just rendering that page instead of showing directory/file structure present in the directory.
So how to prevent webserver rendering default html page(like index.htm etc) if foun
d in a directory instead it should show dir/file structure of that directory. How can i achieve this?
There's a :DirectoryIndex configuration for the WEBrick http server. However, the WEBrick project is poor documented.
You can set that option to [] to disable the directory index page look up.
require 'webrick'
include WEBrick
s = HTTPServer.new(
:Port => 2000,
:DocumentRoot => "/home/abc",
:DirectoryIndex => []
)
s.start()

Middleman Output Path

EDIT for clarity:
I'm wondering if it is possible to have set an output path for files in a Middleman build. For organizational purposes I want to group a type of page into a folder to keep it out of the main source directory. However on build/server I would like it to render to a different path:
/source
index.html
/landingpages
landingpage1.html
landingpage2.html
I have :directory_indexes enabled in my config file would like to be able to have the files in landingpage output to the root directory:
/build
index.html
/landingpage1
index.html
/landingpage2
index.html
Is this possible to achieve this somehow using the config.rb file and still show up properly in the sitemap? I would prefer to not have to do this using .htaccess
Thanks
A technique I used in a current project is based around proxies and should also solve your case:
landingpage_templates = Dir['source/landingpages/*.html']
landingpage_templates.map! do |tpl_name|
tpl_name = File.basename(tpl_name).gsub(/.html$/, '')
proxy "/#{tpl_name}/index.html", "/landingpages/#{tpl_name}.html", :ignore => true
end
You should be able to do something like that:
page "/file1/index.html", :proxy => "/somefolder/file1.html"
page "/file2/index.html", :proxy => "/somefolder/file2.html"
I think you're better off using directory indexes instead though and organising your files like:
/source
index.html
file1.html
file2.html
In your config.rb
activate :directory_indexes

Heroku: Creating a simple, static one page website on Cedar

I'm attempting to upload a simple one page web page using Heroku.
I was previously using the Play! Framework but it seems overkill for a single page with some javascript.
+ project/
+ public/
+ css/
...
+ img/
...
+ js/
...
index.html
How do I upload a basic set of static files to Heroku? There seems to be no documentation on their website on how to do this.
It is not the purpose of Heroku to host static websites. However, you still can do it but you have to create either a Ruby on Rails, Play, etc. project, add the HTML in the folders.
Heroku doesn't really support static web pages, it supports Apps. However, a static web page can trivially be 'enhanced' to be a PHP application by adding a dummy index.php.
So if you want to host a file foo.html as a Heroku app Foo, then:
1. Create Foo on Heroku.
2. [Clone empty repository to local directory] git clone git#heroku.com:Foo.git -o heroku
3. touch index.php
4. [add foo.html]
5. git add .
6. git commit -m 'test'
7. git push heroku master
Heroku has a guide to doing this with Rack: https://devcenter.heroku.com/articles/static-sites-ruby
Basically, create a simple Rack app with a config.ru file:
use Rack::Static,
:urls => ["/images", "/js", "/css"],
:root => "public"
run lambda { |env|
[
200,
{
'Content-Type' => 'text/html',
'Cache-Control' => 'public, max-age=86400'
},
File.open('public/index.html', File::RDONLY)
]
}
a Gemfile:
source "https://rubygems.org"
gem 'rack'
and a public folder with an index.html file and folders for other assets, structured like this:
my_site/config.ru
my_site/Gemfile
my_site/public/index.html
my_site/public/css
my_site/public/images
my_site/public/js
And someone has made a site that will generate all the necessary files for you: http://herokustaticmagico.herokuapp.com/

configure apache for Zend Framework (1.12) project on Mac OS X Lion

I've got a ZF 1.12 project installed on Mac OS X Lion. When I point my browser to ...
http://localhost/~myusername/zendproj/public/index/index
... it loads the page as expected. it also works for other actions within the Index controller. Ex:
http://localhost/~myusername/zendproj/public/admin/index
When I view other controllers ...
http://localhost/~myusername/zendproj/public/admin/index
... I get this error
An error occurred
Page not found
Exception information:
Message: Invalid controller specified (~name)
Stack trace:
#0 /usr/local/zend/share/ZendFramework/library/Zend/Controller/Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#1 /usr/local/zend/share/ZendFramework/library/Zend/Application/Bootstrap/Bootstrap.php(97): Zend_Controller_Front->dispatch()
#2 /usr/local/zend/share/ZendFramework/library/Zend/Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#3 /Users/myusername/Sites/zendproj/public/index.php(26): Zend_Application->run()
#4 {main}
Request Parameters:
array (
'controller' => '~myusername',
'action' => 'zendproj',
'public' => 'admin',
'module' => 'default',
)
why would my vhost/.htaccess config work for one controller but not the other? thanks
The Apache mod_userdir path is confusing the router.
Since I would assume in your production environment the ZF app will not be accessed out of a user folder (~user), I'd suggest setting up a dummy host entry so you can access your app locally using a hostname.
Edit /private/etc/hosts and add an entry like:
127.0.0.1 zendapp www.zendapp
Then try accessing http://zendapp to load your application.
Depending on how Apache is set up, you may need to create a vhost for zendapp that points to your application's public folder, or just add a ServerAlias to an existing vhost so Apache recognizes the hostname.

CKeditor & KCFinder in localhost

I am a building a website locally and I am using CKeditor with KCFinder at a part of it. CKEditor runs properly and KCFinder Upload Tab is also visible, so I guess my installation was correct.
BUT! When I try to upload an image using the KCFinder module ("Browse" then "Send to server") I get an error message showing in the same popped-up window saying:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost
03/01/12 14:31:05
Apache/2.2.21 (Win32) PHP/5.3.8
I have Windows 7, running it in localhost with Easy PHP and the local path to my target folder is:
C:\PROGRA~2\EASYPH~2.1\www\electro\kcfinder\upload
In my kcfinder/config.php I have:
'uploadURL' => "/upload",
'uploadURL' => "../upload",
'uploadDir' => "",
'uploadDir' => "C:\PROGRA~2\EASYPH~2.1\www\electro\kcfinder\upload",
as instructed by the official related thread here.
Anyone has any idea what might be wrong?
EDIT:
Solved it. Needed to change the paths on both KCFinder/config.php AND CKEditor/config.js. Since my paths are:
The project path:
C:\PROGRA~2\EASYPH~2.1\www\electro
and it has the subfolders "ckeditor" and "kcfinder" and I want to have the folder "kcfinder/upload" as the target folder of the filed to be uploaded, then the following changes need to made...
ckeditor/config.js:
CKEDITOR.editorConfig = function(config) {
config.filebrowserBrowseUrl = '../electro/kcfinder/browse.php?type=files';
config.filebrowserImageBrowseUrl = '../electro/kcfinder/browse.php?type=images';
config.filebrowserFlashBrowseUrl = '../electro/kcfinder/browse.php?type=flash';
config.filebrowserUploadUrl = '../electro/kcfinder/upload.php?type=files';
config.filebrowserImageUploadUrl = '../electro/kcfinder/upload.php?type=images';
config.filebrowserFlashUploadUrl = '../electro/kcfinder/upload.php?type=flash';
};
kcfinder/config.php:
'uploadURL' => "upload",
'uploadDir' => "",
For some reason it needed the ../ while it was already in the same folder. I don't understand why, but it works.
Now, I would like to say how displeased I am at the developer of the KCFinder where people with the same issue or others on its support forum the given "help" was things like "RTFM", "Do better searches" etc. As if everyone was born an experienced programmer.
I actually found the answer shortly after I posted my answer. It seems that the path system on ckeditor/config.js doesn't really work as a normal path usually works. so, you have to play around with the "../" and try to find out where it is aiming at. In my case, I didn't need any "../" to refer to a file that was in a separated folder one level up. So the final code for me was:
CKEDITOR.editorConfig = function(config) {
config.filebrowserBrowseUrl = 'kcfinder/browse.php?type=files';
config.filebrowserImageBrowseUrl = 'kcfinder/browse.php?type=images';
config.filebrowserFlashBrowseUrl = 'kcfinder/browse.php?type=flash';
config.filebrowserUploadUrl = 'kcfinder/upload.php?type=files';
config.filebrowserImageUploadUrl = 'kcfinder/upload.php?type=images';
config.filebrowserFlashUploadUrl = 'kcfinder/upload.php?type=flash';
};
when actually should be '../kcfinder/browse.php?type=files'
Hope it helps...

Resources