Jump to content


Photo

another newbie needs help


  • Please log in to reply
7 replies to this topic

#1 sinisake

sinisake
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts
  • LocationSerbia,

Posted 14 October 2006 - 10:18 AM

Hello to all,
i would like to turn this address:
http://localhost/htdocs/shoping/index.php?kategorija=Sapuni&id=1
to something like:
http://localhost/htdocs/shoping/Sapuni/1.html (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 on
Options +FollowSymlinks
RewriteBase /
RewriteRule ^\.htaccess$ - [F]
RewriteRule ^(.*)shoping/(.*)/(.*)$ $1index.php?kategoria=$2&id=$3

Btw,mod rewrite module is turned on

Thanks in advance!

#2 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 14 October 2006 - 10:51 AM

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.
RewriteEngine On
RewriteBase /htdocs/shoping/
RewriteRule ^([a-zA-Z]+)/([0-9]+).html$ index.php?kategoria=$1&id=$2

I dont know if this is a tupo but shoping is spelt shopping (note 2 p's)

#3 sinisake

sinisake
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts
  • LocationSerbia,

Posted 14 October 2006 - 11:25 AM

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/htd...g/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 ::)

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 14 October 2006 - 01:42 PM

Try to use full paths eg: http://localhost/path/to/various/files rather than relative paths.

#5 sinisake

sinisake
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts
  • LocationSerbia,

Posted 14 October 2006 - 07:24 PM

Thank you.


#6 sinisake

sinisake
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts
  • LocationSerbia,

Posted 16 October 2006 - 07:58 AM

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.


#7 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 16 October 2006 - 06:20 PM

You use php. So use the $_SERVER['hostname'] variable to get your domain name and do something like this:

<?php echo 'http://' . $_SERVER['HOSTNAME'] . 'com' ?>/path/to/file_here

Or hard code it in to a file that always gets included/required into your PHP scripts.

#8 sinisake

sinisake
  • Members
  • PipPipPip
  • Advanced Member
  • 63 posts
  • LocationSerbia,

Posted 16 October 2006 - 06:35 PM

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:-))




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users