SitePoint Sponsor |
|
User Tag List
Results 1 to 13 of 13
Thread: another mod rewrite question...
-
Jan 7, 2004, 15:46 #1
- Join Date
- Jan 2004
- Location
- London
- Posts
- 8
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
another mod rewrite question...
ive spent ages and ages on the net trying to get this work and tons of topics on this board. i came across a article which had exactly what i wanted. all i had to do was upload a 4/5 line htaccess file (Unfortunately it didnt work ), everything else ive seen requires lines and lines!
Anyways this is what i wanted to do..
i have a site where i have the following (examples;have various product items /categories etc...)
http://www.mysite.co.uk/category.php?n=12 ( category)
http://www.mysite.co.uk/ware.php?id=520 (product)
http://www.mysite.co.uk/scategory.php?n=22 (subcategory)
i would like to ( suprise suprise) make them into normal urls
something like www.mysite.co.uk/product/520
etc
Help will be really really apperciated.
Thank you.
-
Jan 7, 2004, 15:50 #2
- Join Date
- Jul 2001
- Location
- Italy
- Posts
- 4,514
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by chetas
something like this ?
/.htaccess
Code:RewriteEngine On RewriteRule ^product/([0-9]+)/?$ /ware.php?id=$1 [L] RewriteRule ^subcategory/([0-9]+)/?$ /subcategory.php?id=$1 [L] RewriteRule ^category/([0-9]+)/?$ /category.php?id=$1 [L]
-
Jan 7, 2004, 15:53 #3
- Join Date
- Jan 2004
- Location
- London
- Posts
- 8
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi so all i do is paste that into a text file upload it, call it .htaccess and it should work?
ps thanks for the quick reply! im impressed
-
Jan 7, 2004, 15:57 #4
- Join Date
- Jul 2001
- Location
- Italy
- Posts
- 4,514
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Yes
-
Jan 7, 2004, 15:58 #5
- Join Date
- Jan 2004
- Location
- London
- Posts
- 8
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
i pasted it and well the site seem to be working as normal- cant see no difference in the urls. did i make a mistake?
-
Jan 7, 2004, 16:02 #6
- Join Date
- Jul 2001
- Location
- Italy
- Posts
- 4,514
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You should try:
example.com/product/110
and it should go, internally, to
example.com/ware.php?id=110
Remember that mod_rewrite can ``translate'' requests.
It cannot convert dynamic links from the html generated by your php scripts.
-
Jan 7, 2004, 16:12 #7
- Join Date
- Jan 2004
- Location
- London
- Posts
- 8
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by pippo
oh ok. woohooo it works except now my cart dont workand the images are all coming up as dead links as they are looking them in product/
How would i force the cart system to write the dynamic url as normal ones. as i have a custom cart, i suppose its not as simple
-
Jan 7, 2004, 16:22 #8
- Join Date
- Jul 2001
- Location
- Italy
- Posts
- 4,514
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
I worked with a client that had cart system him too.
Basically writing mod_rewrite, my job, is one part of the task,
the remain task is to generate html containing static urls.
In his case he had to change manually some links in some pages as:
from
<a href="%%script_loc%%?user_action=category&category=%%urlcategory%%">%%category%%</a>
to
<a href="category/%%urlcategory%%">%%category%%</a>
Sometimes it could not be so that easy...
About broken images, yep that client had them too, is more probably due to the usage of relative links for images.
You should use absolute images links.
Because originally you had:
example.com/ware.php?id=110
<img src="images/pippo.gif">
so the browser would have asked
example.com/images/pippo.gif
but with static urls you have
example.com/product/110
<img src="images/pippo.gif">
so the browser will ask
example.com/product/images/pippo.gif
using an absolute path you will be fine
<img src="/images/pippo.gif">
-
Jan 7, 2004, 16:29 #9
- Join Date
- Jan 2004
- Location
- London
- Posts
- 8
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
vc
-
Feb 28, 2004, 14:24 #10
- Join Date
- Jan 2004
- Location
- London
- Posts
- 8
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Im back. ive rewritten all the links as direct urls.
but now i got this problem
http://www.mysite.co.uk/product/520?...02130873299b18
which means after all my hard effort, google still aint spidering. HELP PLEASE!!!!!!
-
Feb 28, 2004, 14:27 #11
I don't know what software you're using, but you'd obviously need to find a way to turn off session ID's. You could also write some scripting where if Googlebot is visiting your page, turn off session ID's just for that. It all depends on what you're running though.
.
Zach Holman
good-tutorials — blog — twitter — last.fm
-
Feb 28, 2004, 14:35 #12
- Join Date
- Jan 2004
- Location
- London
- Posts
- 8
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hi lo0ol [] , its a custom developed cart.
i think turning off sessions will mean a total rewrite of the cart system :S ot would it be simple?
what would scripting involve.. i suppose i would need it for goggle, yahoo etc...
-
Mar 4, 2004, 13:48 #13
- Join Date
- Jan 2004
- Location
- London
- Posts
- 8
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
anyone else?
Bookmarks