sinisake Posted October 14, 2006 Share Posted October 14, 2006 Hello to all,i would like to turn this address:[b]http://localhost/htdocs/shoping/index.php?kategorija=Sapuni&id=1[/b]to something like:[b]http://localhost/htdocs/shoping/Sapuni/1.html [/b] (extension is not mandatory)I tried on other forums,and i get this.i put this in htaccess file in 'shoping 'directory,but it doesn't work...RewriteEngine onOptions +FollowSymlinksRewriteBase /RewriteRule ^\.htaccess$ - [F]RewriteRule ^(.*)shoping/(.*)/(.*)$ $1index.php?kategoria=$2&id=$3Btw,mod rewrite module is turned onThanks in advance! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 14, 2006 Share Posted October 14, 2006 Dont use .* it is greedy, instead use a-zA-Z for (case insensitve) strings 0-9 for integers. Prehaps have a good read on regular expressions.[code]RewriteEngine OnRewriteBase /htdocs/shoping/RewriteRule ^([a-zA-Z]+)/([0-9]+).html$ index.php?kategoria=$1&id=$2[/code]I dont know if this is a tupo but shoping is spelt shopping (note 2 p's) Quote Link to comment Share on other sites More sharing options...
sinisake Posted October 14, 2006 Author Share Posted October 14, 2006 Thank you,i just tested it,but i don't understand some things...When i type something like this in adress bar of browser:http://localhost/htdocs/shoping/Sapuni/1.html i get page without any formating(pages layout is controlled via external css file)...And yes,i make typos(i am not native english speaker/writer-can you believe ::) Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 14, 2006 Share Posted October 14, 2006 Try to use full paths eg: http://localhost/path/to/various/files rather than relative paths. Quote Link to comment Share on other sites More sharing options...
sinisake Posted October 14, 2006 Author Share Posted October 14, 2006 Thank you. Quote Link to comment Share on other sites More sharing options...
sinisake Posted October 16, 2006 Author Share Posted October 16, 2006 But,now i have big problem with script changing.If i change addresses...script don't work anymore...and i don't have idea how to make it works.If someone have experience in this field,i need just some generaly advices about it.Thanks in advance. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 16, 2006 Share Posted October 16, 2006 You use php. So use the $_SERVER['hostname'] variable to get your domain name and do something like this:[code=php:0]<?php echo 'http://' . $_SERVER['HOSTNAME'] . 'com' ?>/path/to/file_here[/code]Or hard code it in to a file that always gets included/required into your PHP scripts. Quote Link to comment Share on other sites More sharing options...
sinisake Posted October 16, 2006 Author Share Posted October 16, 2006 Thank you ,but i actually didn't ask for it...I thought about changes of code which is dependable on vars from address bar of browser(how to get vars if there is no vars).However,i solve problem with some modifications of script(i expected even more modifications,but it works correctly now,with just few:-)) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.