On my site when a link is clicked, the adress bar in the browser shows this URL:

http://www.enkelt-webdesign.dk/index.php?sid=1&titel=FORSIDE

I would lke the URL to appear like this:
http://www.enkelt-webdesign.dk/Forside

I have this code in my .htacess file which is not working as it is:

<ifModule mod_rewrite.c>
RewriteEngine on
#Regler til index.php
RewriteRule ^Forside$ index.php?sid=1&titel=FORSIDE
</ifModule>

THIS IS ACTUALLY WORKING, WHEN THIS LINKED IS FOLLOWED - BUT THEN WHEN I CLICK ON THE LINK AFTER I HAVE ARRIVED TO THE PAGE, THEN I GET THE UGLY URL WITH THE QUERY STRING AGAIN. HOW CAN I KEEP THE PRETTIER URL WHEN THE ON SITE LINK IS CLICKED??

Isnt it correct to first specify the text/word, you want to replace with?

And just after write the entire line that you want stripped away from the URL?

In my case I want to change the entire query string, and replace it with a SEO friendly word for the user to see. (Well in this case: www.domain.dk/Forside)

What am I dong wrong?

My navigation is build like this:

function subject_navigation($connection){
$subjectset = mysqli_query($connection, "SELECT id, titel, linknavn FROM subjects ORDER BY pos ASC");
while($subject = mysqli_fetch_array($subjectset)){
$linknavn = $subject['linknavn'];
$linknavn = strip_tags($linknavn);
$sid = $subject['id'];
$subjectlinklabel = $subject['linknavn'];
// Class for aktivt link:
if(isset($_GET['sid']) && $sid==$_GET['sid']){
$active = 'class="aktivt_link"';	
} else {
$active = '';	
}
echo '<li>
<a href="index.php?sid=' .$sid . '&amp;titel='.$linknavn.'">' . $subjectlinklabel . '</a></li>';
	}
}

Should my $_GET be constructed differently than shown above? I mean whats "inside" of the a tag?

Regards, klemme

Change the echo on line 15 to output it the way you want.

<a href="/' . $linknavn . '?sid=' . $sid . '">' . $subjectlinklabel . '</a></li>';

This gave me a 404 error :-/

Well I am able to write directly into the URL, using "the pretty URL", and i get the right page, so thats great so far :-)

But I am not sure how I can "KEEP IT THERE", so when the link(Forside)-(build as shown in the top post) is clicked, I still only see domain.dk/Forside - It changes back to the query string, I wanted to get rid of. So it is not working when the navigation is used!

Bottom line, I can now write the pretty URL and get to the right page, but I cant keep the pretty url after a link is clicked.

How do I modify the mod_rewrite to accomplish that?

I just get 404 errors when I try to build the navigation that way :-/

I cant leave out index.php?

But I can put the title before the sid in the query string, but then I still need to cahnge the url, so that doesnt really change the situation, other than it is something else I need to change.

Or maybe i simply dont understand what you mean..

What is the sid for ? Does it really have to be in the url ?

Apart from that, on my site I use page as my index.php. every parameter I use comes after a slash. Using the htaccess you can tell apache to treat files without extensions as php files. you can see it in action on onderwaterwereld.org. I use two files there, page and library. Both are similar, just use different data and templates.

sid = id from the database, the entire site is a cms I have made, and sid is the unique id used for getting the right content for the different subjects.

In another table I have the pages for the submenu, which contains a subjectid = the id (sid) from the subjects table.

So i need these values to be able to run the site at all.

So I dont have any other files, apart from index.php? - which swaps out the content depending what sid (subjectid) or pid(pageid) is set.

So it is "simply the query string" I want to modify, depending on what sid is set..

Just dont get how to do it..

Since you need the sid, you may have to build your url's like

domain.dk/102/Forbide
domain.dk/182/Sitemap

and change the rewrite to capture both. Is that what you want ?

Yep something like that.

I wanted to strip the entire querystring - and then add a rewrite_rule that adds a custom/seo friendly word, relevant to the content of the page.

As it is now my urls is like this:

domainname.dk/sid=1&titel=FORSIDE

Is it not possible to change it to:

domainname.dk/Forside

And then behind the scenes, let apache read the top one, which works for database queries?

If Apache removes the sid from the url, you can no longer read it using GET, so it is lost.

.htaccess is supposed to be able to redirect without rewriting the url in the address bar, but I haven't been able to get it to work for probably 5 years. It used to work ok when I first started using it, but no longer. Might be a change in Apache...

RewriteRule ^(\d+)/(.*)$ index.php?sid=$1&titel=$2

Okay so i have this:

RewriteEngine on
RewriteRule ^(\d+)/(.*)$ index.php?sid=$1&titel=$2

based on this navigation:

<a href="index.php?sid=' .$sid . '&amp;titel='.$linknavn.'">' .$subjectlinklabel . '</a>

And it throws me an 500 error, my gooood :-/

If you're still trying, the way I got round this is to actually create a file with the relevant address, set the variables in it and have it include what I need.

e.g.

<?php
ob_start("ob_gzhandler");
$script_root = "../";
include "../inc/settings.inc";
include "../inc/siteinfo.inc";
include "../inc/functions.inc";
$crop="broccoli";
include "./showcrop.inc";
?>