Jump to content

another newbie needs help


sinisake

Recommended Posts

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 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!
Link to comment
Share on other sites

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 On
RewriteBase /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)
Link to comment
Share on other sites

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 ::)
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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:-))
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.