I am using this URL rewriting with PHP The Folder structure for rewriting the URLs. I am done it is working fine but after rewrite the URL the $_GET['cat_id']
is not working. How to get the data now? please help. My project is here http://199.192.21.232/~admin/category/men-items
Script
define( 'INCLUDE_DIR', dirname( __FILE__ ) . '/' );
$rules = array(
'picture' => "/picture/(?'text'[^/]+)/(?'id'\d+)", // '/picture/some-text/51'
'album' => "/album/(?'album'[\w\-]+)", // '/album/album-slug'
'category' => "/category/(?'category'[\w\-]+)", // '/category/category-slug'
'page' => "/page/(?'page'about|contact)", // '/page/about', '/page/contact'
'post' => "/(?'post'[\w\-]+)", // '/post-slug'
'home' => "/" // '/'
);
$uri = rtrim( dirname($_SERVER["SCRIPT_NAME"]), '/' );
$uri = '/' . trim( str_replace( $uri, '', $_SERVER['REQUEST_URI'] ), '/' );
$uri = urldecode( $uri );
foreach ( $rules as $action => $rule ) {
if ( preg_match( '~^'.$rule.'$~i', $uri, $params ) ) {
include( INCLUDE_DIR . $action . '.php' );
exit();
}
}
include( INCLUDE_DIR . '404.php' );
HTaccess
RewriteEngine On
RewriteRule ^/.*$ index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [QSA,L]