jimmyoneshot Posted January 4, 2011 Share Posted January 4, 2011 I have the following rewrite rule in place:- RewriteRule ^Popular\.html$ index.php?getbypopular=1 However I have added some pagination to that page which I also want to rewrite Popular.html/Page1 to index.php?getbypopular=1&page=1 or whatever page it is can anyone please help me out with this? Quote Link to comment https://forums.phpfreaks.com/topic/223393-mod-rewrite-with-multiple-conditions/ Share on other sites More sharing options...
jimmyoneshot Posted January 4, 2011 Author Share Posted January 4, 2011 Whoops when I said conditions in the title I meant to say parameters Quote Link to comment https://forums.phpfreaks.com/topic/223393-mod-rewrite-with-multiple-conditions/#findComment-1154787 Share on other sites More sharing options...
jimmyoneshot Posted January 5, 2011 Author Share Posted January 5, 2011 BUMP ????? Quote Link to comment https://forums.phpfreaks.com/topic/223393-mod-rewrite-with-multiple-conditions/#findComment-1155047 Share on other sites More sharing options...
jimmyoneshot Posted January 6, 2011 Author Share Posted January 6, 2011 I wish there was a more active mod rewrite forum than this Can any moderators help if you see this? Quote Link to comment https://forums.phpfreaks.com/topic/223393-mod-rewrite-with-multiple-conditions/#findComment-1155757 Share on other sites More sharing options...
jimmyoneshot Posted January 7, 2011 Author Share Posted January 7, 2011 This may come as a suprise but I was posting this question hoping for uhm oh well I don't know...A REPLY!!!!!! ANSWER ME!!!!!!!!!!!!!!!!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/223393-mod-rewrite-with-multiple-conditions/#findComment-1156394 Share on other sites More sharing options...
DavidAM Posted January 8, 2011 Share Posted January 8, 2011 I'm not an expert with rewrite, but my first attempt would be adding another rule (after the one you have): RewriteRule ^Popular\.html/Page(\d+)$ index.php?getbypopular=1&page=$1 Quote Link to comment https://forums.phpfreaks.com/topic/223393-mod-rewrite-with-multiple-conditions/#findComment-1156571 Share on other sites More sharing options...
jimmyoneshot Posted January 8, 2011 Author Share Posted January 8, 2011 Thanks for the help David It still appears it's not working though. The page I'm using the link from is this:- http://www.mytestsite.com/myshopsite/myproducts.co.uk/Popular.html I have a link on that page that goes to i.e. it's href is:- /myshopsite/myproducts.co.uk/Popular.html/Page$pagenum with $pagenum being the page number in question If the page 2 link is clicked for example it goes to this page:- http://www.mytestsite.com/myshopsite/myproducts.co.uk/Popular.html/Page2 but the problem is I'm getting a 404 - not found message on that page However if I type into the url bar:- http://www.mytestsite.com/myshopsite/myproducts.co.uk/index.php?getbypopular=1&page=2 It works as it should. It's totally confusing Is this a mistake in the rewrite rule/file? Quote Link to comment https://forums.phpfreaks.com/topic/223393-mod-rewrite-with-multiple-conditions/#findComment-1156720 Share on other sites More sharing options...
jimmyoneshot Posted January 8, 2011 Author Share Posted January 8, 2011 Sorry I meant to say the href of the page links on that page is:- Popular.html/Page$pagenum Quote Link to comment https://forums.phpfreaks.com/topic/223393-mod-rewrite-with-multiple-conditions/#findComment-1156733 Share on other sites More sharing options...
DavidAM Posted January 8, 2011 Share Posted January 8, 2011 As I said, I'm no expert at rewrite. I'm not really sure what regexp constructs are allowed in it. You might try changing it to this: RewriteRule ^Popular\.html/Page([0-9]*)$ index.php?getbypopular=1&page=$1 just in case the "\d" construct is not allowed. Note: you could add a custom error page using something like this in the .htaccess ErrorDocument 404 /err404.php Then write the err404.php file to just dump $_SERVER to the screen <?php echo '<PRE>'; print_r($_SERVER); So you can see what the request looks like. It might help you to debug this. Note: Do NOT do this on a production server, it could show information you don't want visible to hackers. If you absolutely have to put it in production, remove the file and directive as soon as you get the results. If you have access to the main http.conf file, you can turn on rewrite logging. This dumps ALOT of information about the rewrite process to a log file. It cannot be set in the .htaccess file (at least not to my knowledge) and should not be left on in production because it slows things down and it dumps ALOT of information into log files. Did I mention that the rewrite logging will write ALOT of stuff to log files using up large amounts of disk space? Quote Link to comment https://forums.phpfreaks.com/topic/223393-mod-rewrite-with-multiple-conditions/#findComment-1156734 Share on other sites More sharing options...
jimmyoneshot Posted January 8, 2011 Author Share Posted January 8, 2011 Hi David. That new rule seems to work fine i.e. all of the information for the selected page shows up however it's strange because in the pages pages themselves it seems all css is removed. I think it may be a problem with the links in my site itself. Let me explain. The first page of my site is:- http://www.mytestsite.com/myshopsite/myproducts.co.uk/ I have a few links across the top of that page. One of the links goes to the popular page and it's href is:- Popular.html I already have a rewrite rule in place for this which works:- RewriteRule ^Popular\.html$ index.php?getbypopular=1 So the popular page looks like this:- http://www.mytestsite.com/myshopsite/myproducts.co.uk/Popular.html I have pagination links on that page i.e. so only a certain amounts of products can be shown. The href's of each of these page links are:- Popular.html/Page$pagenum When I have your rewrite rule in place clicking the page 2 link for example goes to:- http://www.mytestsite.com/myshopsite/myproducts.co.uk/Popular.html/Page2 where it seems the right items are being shown but there is no css for some reason. However when I click another page link such as page 1 for example from the page 2 page it goes to:- http://www.mytestsite.com/myshopsite/myproducts.co.uk/Popular.html/Popular.html/Page1 Which of course does not exist. Is this a problem with my href of the links? The css disappearing is weird too. Again thanks for trying to help. Quote Link to comment https://forums.phpfreaks.com/topic/223393-mod-rewrite-with-multiple-conditions/#findComment-1156745 Share on other sites More sharing options...
jimmyoneshot Posted January 8, 2011 Author Share Posted January 8, 2011 OK I've changed my css link from:- <link href="styles.css" rel="stylesheet" type="text/css"/> to:- <link href="http://www.mytestsite.com/myshopsite/myproducts.co.uk/styles.css" rel="stylesheet" type="text/css"/> and that makes the css work on the pages pages however now no images are appearing. Does this mean I'll have to add in the full site address for every image like I have done with the css link? Rewriting is the biggest pain in the nuts in the history of all things web related EDIT - It seems adding the full site address i.e. http://www.mytestsite.com/myshopsite/myproducts.co.uk/images/ before every image fized the images problem However I still have the page problem i.e. if I go to page 2 or any other page on the popular page it goes to something like this:- http://www.mytestsite.com/myshopsite/myproducts.co.uk/Popular.html/Page2 BUT if I try to go to another page FROM that page such as page 1 it does this:- http://www.mytestsite.com/myshopsite/myproducts.co.uk/Popular.html/Popular.html/Page1 I think it's my hrefs or something. Quote Link to comment https://forums.phpfreaks.com/topic/223393-mod-rewrite-with-multiple-conditions/#findComment-1156759 Share on other sites More sharing options...
jimmyoneshot Posted January 9, 2011 Author Share Posted January 9, 2011 I managed to get it fixed by including full urls in everything basically. Thanks a lot for the help David. Quote Link to comment https://forums.phpfreaks.com/topic/223393-mod-rewrite-with-multiple-conditions/#findComment-1156868 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.