Jump to content

Archived

This topic is now archived and is closed to further replies.

sinisake

another newbie needs help

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!

Share this post


Link to post
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)

Share this post


Link to post
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 ::)

Share this post


Link to post
Share on other sites
Try to use full paths eg: http://localhost/path/to/various/files rather than relative paths.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
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:-))

Share this post


Link to post
Share on other sites

×

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.