PaulBruk2010 Posted February 6, 2010 Share Posted February 6, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/191180-sef-urls-htaccess-showing-ugly-url/ Share on other sites More sharing options...
wildteen88 Posted February 6, 2010 Share Posted February 6, 2010 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] Quote Link to comment https://forums.phpfreaks.com/topic/191180-sef-urls-htaccess-showing-ugly-url/#findComment-1008022 Share on other sites More sharing options...
PaulBruk2010 Posted February 6, 2010 Author Share Posted February 6, 2010 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? Quote Link to comment https://forums.phpfreaks.com/topic/191180-sef-urls-htaccess-showing-ugly-url/#findComment-1008025 Share on other sites More sharing options...
wildteen88 Posted February 6, 2010 Share Posted February 6, 2010 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"> Quote Link to comment https://forums.phpfreaks.com/topic/191180-sef-urls-htaccess-showing-ugly-url/#findComment-1008028 Share on other sites More sharing options...
PaulBruk2010 Posted February 6, 2010 Author Share Posted February 6, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/191180-sef-urls-htaccess-showing-ugly-url/#findComment-1008036 Share on other sites More sharing options...
PaulBruk2010 Posted February 7, 2010 Author Share Posted February 7, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/191180-sef-urls-htaccess-showing-ugly-url/#findComment-1008330 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.