Category Archives: Apache

Another mod_rewrite trailing slash question

Questions: I have the following rewrite rules in my .htaccess file: RewriteEngine on RewriteRule ^news/([0-9]+)/?$ /?action=news&start=$1 [L] RewriteRule ^man/([a-zA-Z0-9_]+)/?$ /?action=man&page=$1 [L] RewriteRule ^([a-zA-Z0-9_]+)/?$ /?action=$1 [L] All of then end with a /? to check for an optional trailing slash. This works – it means I can use either or to get to the… Read More »

How to get the HTTP_HOST from Rails?

Questions: I need to set some server specific variables in a rails application that will run on at least two different servers. What is the best way to get the request’s HTTP_HOST value in order to know what is the current server and set these variables accordingly? I’m using Apache 2 with Passenger. Answers: Think… Read More »

mod_jk or mod_proxy_ajp for clustering tomcat and ssl

Questions: Please tell me what is better in supporting clustering and ssl between mod_jk and mod_proxy_ajp. Thank you. Answers: Regarding SSL, it should not make any difference if you use mod_jk or mod_proxy_ajp. Especially if you offload SSL in apache and not in tomcat, the transport between httpd <-> tomcat (mod_jk/mod_proxy_ajp) would not be affected.… Read More »

How to rewrite .php to .html with mod_rewrite rules

Questions: Prolly an easy one.. I am trying to study up on mod_rewrite and ran into an issue Here is my url I want the page to be able to take How would I do that? Answers: Options +FollowSymLinks RewriteEngine on RewriteRule (.*)/(.*)\.html$ index.php?id=$1&title=$2 Questions: Answers: RewriteEngine on RewriteRule ^(\d+)/(\w+).html$ index.php?id=$1&title=$2

php most memory efficient way to return files

Questions: so i have a bunch of files, some can be up to 30-40mb and i want to use php to handle security of the files, so i can control who has access to them that means i have a script sort of like this rough example $has_permission = check_database_for_permission($user, filename); if ($has_permission) { header(‘Content-Type:… Read More »

Source code security on Trac

Questions: I have trac set up together with subversion. I want to allow some people to be able to add tickets, but I don’t want them to access the repository. There will be other users who will be able to access the repo via trac. Currently I am using Apache 2 for authentication. How secure… Read More »

Apache does not rewrite request if file on path exists

Questions: I’m doing a rewrite with mod_rewrite on every request that does not match an existing file or directory. This is my configuration: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.*$ /index.php [NC,L] This is used to map URLs like /abc/foo or /abc/foo/10 to my app. And it works just fine. To improve… Read More »

Laravel permission denied in storage/meta/services.json

Questions: Well, this error is so know but in my case I could not mitigate it in my side. I have migrated a laravel-4 installation to another server and for the first time accessed I get this error: file_put_contents(/var/www/html/MyApp/app/storage/meta/services.json): failed to open stream: Permission denied I have followed different googled aswers as below Can't… Read More »

How to run sails.js application on port 80 with example?

Questions: I have to put sails.js in port 80, but apache is already using it. How can I put both (sails.js and apache) on the same port 80? I need it because in my company all the ports are blocked except for PORT 80. (This is a realtime application with nodejs and (websockets) and… Read More »