I have a page which is http://www.example.com/page_name.php?var1=dynamic_var1&var2=dynamic_var2
I want to use .htaccess file to make it look like this
http://www.example.com/page_name/dynamic_var1/dynamic_var2
I have tried this so far
RewriteRule ^page_name/(.*)/(.*)$ page_name.php?var1=$1&var2=$2 [NC]
and the problem is when this is going to database it goes like this
SELECT * FROM table_name WHERE id=dynamic_var1/dynamic_var2.php/dynamic_var1 LIMIT 1
and i also tried this
RewriteRule page_name/(\w+)/(\w+) page_name.php?var=$1&var2=$2
it is loading the page but without any pictures or css file or anything, and when i used firebug it said that it failed to load the URL given.
and when i tried this
RewriteRule ^page_name/(\w+)/(\w+)$ page_name.php?var=$1&var2=$2
It gave me internal server error
Thanks in advance,
Don’t try split the URL from within the
.htaccessfile. Why don’t you try simply passing the entire query string to yourindex.phpor any other script you want and parse the request there…A much easier way would be to simply redirect all the requests into an
index.phpfile that does something like this –index.php–Given
http://yourdomain.com/user/123Now you have inside of
$URLPartsNow you can easily place these values in your SQL query.
Watch out for SQL injection though! always use
mysql_real_escape_string()and make sure to sanitize any incoming data…