hi all..i am creating a new website and using a .htaccess file which convert web address in the form of querystring..and it works properly in my institute..but not working at home ..is there any special thing to do to use .htaccess file..here is the data of .htaccess....... this file should store first address after index.php in to section variable as query string and next one into action variable and so on for e.g. www.example.com/ex1/ex2 above address should word as www.example.com/index.php?section=ex1&action=ex2 but when i am putting the address then it shows the error "The requested URL www.example.com/ex1/ex2 was not found on this server.
Do the other rules work, other than that huge one? If not, you probably don't have mod_rewrite installed/configured properly on your apache server. Or, you might, but you don't have your site files picking up .htaccess correctly.
Bloody hell. When you say it works at your institute, but not at home, do you mean you have two installations of the website set up? That's all serverside, so if you're accessing the one resource from two different locations it should work. If you have two installations, try checking your Apache configuration. if you don't have root access to the server, the easiest way is probably to create a simple phpinfo() file and look to see if the mod_rewrite module has been loaded. Personally, I wouldn't create a rule like that. It would be easier to rewrite everything to index.php, and have the PHP script retrieve and format the variables. For instance, on a block of code I just wrote: .htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ dispatcher.php?url=$1 [PT,L] </IfModule> Code (markup): Block of code in dispatcher.php that retrieves the variables from the URL: function dispatchRequest( $passThrough ) { $urlParts = explode( '/', $_GET['url'] ); // Try to fetch the controller/action/vars from the URL query. try { $controller = trim( $urlParts[0] ); $action = $urlParts[1]; $vars = array(); if( isset( $urlParts[2] ) ) { for( $x = 2; $x <= sizeOf( $urlParts ) - 1; $x += 2 ) { $vars[ $urlParts[ $x ] ] = $urlParts[ $x + 1 ]; } } // Otherwise, let's just load up the default values } catch( Exception $e ) { if( ! isset( $controller ) ) $controller = 'index'; if( ! isset( $action ) ) $action = 'index'; if( ! isset( $vars ) ) $vars = array(); } Code (markup): Cut the function off and a bit of it is redundant for your purposes. However from the url http://localhost/pages/view/id/1/action/edit the vars array would be: [id] => 1 [action] => edit Code (markup): Technique like this is probably more beneficial and flexible.