RewriteRule (.*)\\.html$ fetch.php?id=$1
I have this in my htaccess file and it works fine, but I want to know if there is a way to rewrite this so that instead of just pulling the id # i can pull the category and title up instead or will i need to do something like this
RewriteRule (.*)/(.*)/(.*)\\.html$ fetch.php?id=$1&category=$2&title=$3
With this method I can pull the necessary information up but the url can't be written how I want it to look. with the method above I get something very long.
Also if this is what I need to do, how will I go about changing my title to have no spaces and only have dashes inbetween them? I heard that urls don't like spaces. I have read somewhere else they used a php code where the spaces were turned into "-" or "_" to be read into the page but reverted back to be read in sql. Let me know if you need to know more about my situation. Thanks.
<a href="<?php echo $row_getDisplay['post_id']; ?>/<?php echo $row_getDisplay['category']; ?>/<?php echo urlencode($row_getDisplay['title']); ?>.html">
That is the link i'm using to call the thing.
my htaccess looks like this now.
RewriteRule (.)/(.)/(.*)\.html$ fetch.php?id=$1&category=$2&title=$3
When I click on the link the page loads but no CSS. What could be the problem.
Aw, you didn't read the tutorial article linked in my signature which used a situation very similar to this, did you?
As above, the answer is in the tutorial - look for "Missing Support Files."
Thanks Dklynn, your tutorial helped a lot. I remembered reading it before and even saved it as a favorite. I guess I didn't know what I was looking for or what I wanted when I first read it. As of now I excluded my category and just left the ID and Title. I just wanted to make it more SEF instead of seeing ?id=#title=ABZ. I appreciate it. I will be going back to your tutorial as my needs may change in how I want my url shown. Thank again. I've also changed the (.*) to more proper things.
:tup: Thanks for the nice comment. I try to update that tutorial every once in a while when there are new questions asked (which isn't often). Nevertheless, it should be useful as a reference (at least for the sample codes) so check back every so often (as the need arises).
This topic is now closed. New replies are no longer allowed.