Change the query string
RewriteRule /resource/(.+)?(.+) /resource/$1?other_query_string
RewriteRule /resource/(.+)?(.+) /resource/$1?other_query_string
RewriteEngine On RewriteBase /mydir RewriteRule ^mydir/(.*) http://my_other_server.com/other_dir/$1 [P] RewriteRule ^mydir/$ http://my_other_server.com/cgi-bin/other_dir/index.cgi [P] RewriteRule ^cgi-bin/other_dir/index.cgi(.*) http://my_other_server.com/cgi-bin/other_dir/index.cgi$1 [P] # RewriteCond %{REQUEST_URI} ^index.cgi* RewriteRule ^index.cgi(.*) http://my_other_server.com/cgi-bin/other_dir/index.cgi$1 [P] RewriteRule ^mydir/index.cgi(.*) http://my_other_server.com/cgi-bin/other_dir/index.cgi$1 [P] RewriteEngine On RewriteBase /mydir RewriteRule ^mydir/(.*) http://my_other_server.com/other_dir/$1 [P] RewriteRule ^mydir/$ http://my_other_server.com/cgi-bin/other_dir/index.cgi [P] RewriteRule ^cgi-bin/other_dir/index.cgi(.*) http://my_other_server.com/cgi-bin/other_dir/index.cgi$1 [P] # RewriteCond %{REQUEST_URI}… Read More »
Server Variables are variables set by Apache, and held inside the super global array ‘$_SERVER’. They hold very interesting snippits of data available for use, and become very useful when developing PHP projects. $_SERVER[‘REQUEST_URI’] It return the URL in to access the page which is executing the script. If you need to type http://www.example.com/product.php?id=5 to… Read More »
If you want you can include other configuration file into a Virtual Host, but you must not define any other <VirtualHost *:8080> Include /etc/apache2/conf.d/my_other_conf/*.conf </VirtualHost> If you don’t define the virtual host *:80, all the configuration from standard httpd.conf will be loaded in all other Virtual Host.
OpenSuSE 11 has a strange and funny way for loading the modules. If you try to load modules by modifying an .conf file, you will be surprised when you will realize that at the restart, your change will be lost. You have two options: 1. Load that modules only when you need it, in a custom… Read More »
If you have OpenSuSE 11, you will have a big surprise when you try to use mod_rewrite. You will not find any mod_rewrite. The only think you must do is to activate mod_rewrite with the following command: # a2enmod rewrite # rcapache2 restart
When you need to redirect a visitors to different pages depening on a value from a cookie you can use this code: RewriteCond %{HTTP_HOST} ^mydomain.com$ RewriteCond %{HTTP_COOKIE} !MyDomainCookie RewriteRule ^/$ /first-page.htm [R=301,L] RewriteCond %{HTTP_HOST} ^mydomain.com$ RewriteCond %{HTTP_COOKIE} MyDomainCookie=Value1 RewriteRule ^/$ /second-page.htm [R=301,L] RewriteCond %{HTTP_HOST} ^mydomain.com$ RewriteCond %{HTTP_COOKIE} MyDomainCookie=Value2 RewriteRule ^/$… Read More »
If you need to redirect users depending on their web browser, you can use this: RewriteCond %{HTTP_USER_AGENT} ^Mozilla.* RewriteRule ^/$ /homepage.max.html [R=301,L] RewriteCond %{HTTP_USER_AGENT} ^Lynx.* RewriteRule ^/$ /homepage.min.html [R=301,L] RewriteRule ^/$ … Read More »
#! /usr/bin/perl use CGI qw/:standard/; print “Content-type: text/htmlnn”; print “Modify the file:$file<br/><br/>”; $action = param(‘action’); if($action eq “”){ $file_content=””; open (MYFILE, “<“, $file); @lines=<MYFILE>; foreach $l(@lines){ $file_content.=$l; } close (MYFILE); print<<frm; <form action=”modify.cgi” method=”POST”> <textarea name=”file” cols=”150″ rows=”30″> $file_content </textarea> <input type=”hidden” id=”action” name=”action” value=”modify”> <br /><br /> <input type=”submit” value=”Modify!”> </form> frm } if($action… Read More »
Sometime, you don’t find the .so file that you need. In this case you must search for it’s source codes and try to comile it. To have this option, you must have httpd-devel / apache-devel installed on your Linux machine. apxs2 -c -I/usr/include/libxml2 -i mod_line_edit.c This will complile mod_line_edit.so Cheers,