Friendly URL, I'm at a loss

Discuss practical ways rearrange URLs using mod_rewrite.

Friendly URL, I'm at a loss

Postby cl4im3r » Mon Jun 09, 2008 10:37 am

Hi guys, I really pray someone can help me with this.

Heres an example of a page...

www.site.co.uk/article.php?titleurl_art=portal

That i would like to look like this

www.site.co.uk/portal

I have been trying for 3 days to come up with something, and have had no luck. So depressing. Does anyone have the solution? Thnx in advance :o
cl4im3r
 
Posts: 15
Joined: Mon Jun 09, 2008 10:28 am

Postby richardk » Mon Jun 09, 2008 1:10 pm

Try
Code: Select all
Options +FollowSymLinks

RewriteEngine On

# Don't match existing files.
RewriteCond %{SCRIPT_FILENAME} !-f
# Don't match existing directories.
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /article.php?titleurl_art=$1 [QSA,L]
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Manually changing mypage links, or does Mod_rewrite do that?

Postby cl4im3r » Wed Jun 11, 2008 6:34 am

Thnx Alot Rich! that worked a treat, You the man!

I have one question though, now that the URLs for articles are rewritten.

Do i have to manually change my site links to match the new rewritten URLs?

This either sounds stupid to you, or makes sense...

The reason i ask this is because...

If i Physically type the newly rewritten URL: www.site.co.uk/portal

It will go to the right page, and works.

But if i scroll over the same actual link on my site page, which goes to Portal, It Shows the Original Long URL

www.site.co.uk/article.php?titleurl_art=portal

So basically, none of my links show the rewritten URL, They still show the old ones. But if i manually type in the NEW URL's it goes to the right page...Is this normal?

1. Could this be due to some sought of APACHE setting on my server?

2. is this just how Mod Rewrite works, am i meant to somehow change the links on my page to match the new rewritten URLS?

3. Is there something needed in my HTACCESS, to make the OLD URL's appear as the NEW URL's on my site?


Thankyou once again


:D
cl4im3r
 
Posts: 15
Joined: Mon Jun 09, 2008 10:28 am

Postby richardk » Wed Jun 11, 2008 3:10 pm

2. is this just how Mod Rewrite works, am i meant to somehow change the links on my page to match the new rewritten URLS?

Yes that's how it works. Mod_rewrite works on the incoming requests, it does not touch your pages at all.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am


Return to Friendly URLs with Mod_Rewrite

Who is online

Users browsing this forum: No registered users and 19 guests

cron