Help with .htaccess file. mod_rewrite for custom urls?

kugelfang

New Member
Situation:I have a few hundred posts each belonging to a particular category. A] Now when the user visits the home page, the content is irrespective of the category sorted by date.http://www.example.comHe can navigate through different pages like:Type 1: http://www.example.com/3 which corresponds to http://www.example.com/index.php?page=3I can probably do this in mod_rewriteB] The user can then decide to view by category like:Type 2: http://www.example.com/Football which will correspond to http://www.example.com/index.php?page=1&category=FootballHe can then navigate through pages like:Type 3: http://www.example.com/Football/5 which => http://www.example.com/index.php?page=5&category=FootballC] I have a directory called View with index.php in it. It only shows individual posts like:Type 4: http://www.example.com/View/1312 => http://www.example.com/View/index.php?id=1312Here is the mod_rewrite I do:RewriteEngine onRewriteRule ^View/([^/.]+)/?$ View/index.php?id=$1 [L]Now here are the problems I haveIn point C]: http://www.example.com/View/1312 works fine but http://www.example.com/1312/(notice the trailing slash) breaks apart & gives weird results. Q1) So how do I maintain consistency here? Q2) Ideally I would want http://www.example.com/View/1514 to show a 404 Error if there is no post with id 1514, but now I have to manually take care of that in PHP code.What is the right way of dealing with such dynamic urls? especially if the url is wrong.Q3) how do I ensure that http://www.example.com & http://www.example.com/ both redirect to http://www.example.com/index.php?page=1; (mod_rewrite code would be helpful)Please Note that there are only two index.php files. One in the root directory which does everything apart from showing individual posts which is taken care by a index.php in View directory. Is this a logical way of developing a website?
 
Back
Top