I have some really big problems changing the appearences of my urls..

Cant seem to get this to work:

I want to change this url:

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

Into this url:

http://www.enkelt-webdesign.dk/Forside

I have tried many things in my .htacess file now, and just dont get the desired result.

This is what i have now, which does abslutely nothing:

<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^sid=1&titel=FORSIDE$
RewriteRule ^Forside$ /index.php?sid=1&titel=FORSIDE
</ifModule>

Dont I need to match the query string in the RewriteCond, and then in the RewriteRule below it, just state how I want the matched URL to appear?????

Help is highly appreciated, as I am getting grey hair and bald trying to make this work!

When rewriting, assume the url is already in the form you want and then rewrite it to what the web server and php would expect. For example:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(cms|admin|client|public)/(.*) $1/index.php/$2 [PT,L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

Thank you for the answer!!

I have just tried to test this:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(Forside|SEO|CMS|Hosting|Referencer|Kontakt)/(.*) $1/index.php/$2[PT,L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]

But I get no result..

The entire site is run from index.php(querysting....) and gets the sites info, and the links info from the DB.

SO THERE IS NOT ALL THE ABOVE FILES TO BE FOUND. only index.php..

It is only the url/querystring that should appear differently.

There is only going to be 6 pages on the site.

Couldnt I change them one at the time, just to understand the code better?

Can you maybe explain me why this is not working, if I only wanted to change, lets say - the start page (sid=1)

<ifModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{QUERY_STRING} ^sid=1&titel=FORSIDE$ // Wouldnt that identify the querystring?
RewriteRule ^Forside$ /index.php?sid=1&titel=FORSIDE // And then "simply change the appearance of in in the rule"?
</ifModule>

Wouldnt that recognize the querystring behind the scenes, and then just after rewrite it when the proper link is clicked? (Forside..)

Well I know it doesnt, but I thought it would..

Can someone tell me WHY? :-)

Lets say it is just this one url I am looking to change - Am I on the wrong direction, completely?

That rule may not have worked because of the '/' in front of 'index.php'. When using a leading slash, the remap assumes a file directory path (root directory is /.) In the rule below I added the pass-through [pt] flag to prevent this.

Try this. It takes the pretty url and assumes the first parameter is the sid and the second is the title (titel). It ensures that only a url with a number after the first / is considered valid for the rule. http://domain.com/32/Forside becomes http://domain.com/index.php?sid=32&titel=Forside

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([0-9]+)/(.*)$ /index.php?sid=$1&titel=$2 [PT,L]
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.