Jump to content

Recommended Posts

Hi i know enough about PHP to write websites etc.. but im looking at ways to improve my URLS from

 

http://www.mysite.co.uk/show_cat.php?cat_ID=54 

 

to

http://www.mysite.co.uk/category/54

 

I know this aint Useful but this is my first look at Mod Rewrite so once i get this working i can move on..

 

Now i got it working with :-

 

RewriteEngine On    # Turn on the rewriting engine
RewriteRule ^category/([0-9]+)/?$ http://www.mysite.co.uk/show_cat.php?cat_ID=$1  [NC,L]

 

Only problem being if you put in

http://www.mysite.co.uk/category/54

 

It goes to the correct page showing the correct category.. but the URL is showing as the ugly one, so its just working as a Redirect, rather than a re Write?

 

http://www.mysite.co.uk/show_cat.php?cat_ID=54

 

Where have i gone wrong?

 

Cheers Paul

Link to comment
https://forums.phpfreaks.com/topic/191180-sef-urls-htaccess-showing-ugly-url/
Share on other sites

Remove http://www.mysite.co.uk/ from your rewrite rule. Using absolute urls in your rules will redirect the user.

 

RewriteEngine On    # Turn on the rewriting engine
RewriteRule ^category/([0-9]+)/?$ show_cat.php?cat_ID=$1  [NC,L]

Thanks for the reply, that kinda works but now im presented by another problem..  :'(

 

all the images appear broken? because where images are in this path

http://mysite.co.uk/images/2009/more.jpg

 

when sent from the SEF URL new path becomes http://mysite.co.uk/category/images/2009/more.jpg  :'(

 

Note: /category? has appeared in there?

 

Any thoughts?

 

:confused:

If your images are located in http://mysite.co.uk/images/ then start your images path with a / this will always request the images from the root of the url

<img src="/images/file.jpg">

 

Or prepend your sites domain

<img src="http://sitename.com/images/file.jpg">

Hi, yeah , thats what i was afraid of lol.. its quite a big site with some 63 dynamic pages, basically e comerce shopping site, so it means i`ll have to make all the image URLs and Links the full Paths from the root if i want to make it more SEF..

 

Thanks for your help..

 

Paul  :D

Hi, i managed to write another rule to take out the word category from the urls before /category/images.

 

to /images which fixed that.. now just got to go through the site and make sure all links

are full paths and then i think ive got it sussed.. fingers crossed..

 

Cheers Paul.

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.