Mod Rewrite problems...

  • silentdreamer
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: Trapped in the mist of dark desires...

Post 3+ Months Ago

I read a couple of other topics about Mod Rewrite on this forum and several others just to find myself looking for a mod_rewrite package on google.. now that i got one and implemented it, i found myself getting alot of page not founds... heres the Mod_rewrite i used:

Code: [ Select ]
##############################################################
## MOD Title: mod_rewrite
## MOD Author: wGEric < eric@egcnetwork.com > (Eric Faerber) http://eric.best-1.biz
## MOD Description: Use mod_rewrite on your board. It converts your dynamic links to something
##          more Search Engine Friendly
## MOD Version: 1.0.0
##
## Installation Level: Easy/
## Installation Time: 10 Minutes
## Files To Edit: includes/page_header.php
##         includes/page_footer.php
##         .htaccess (may need to)
## Included Files: .htaccess (may need to use)
##############################################################
## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
## in our MOD-Database, located at: http://www.phpbb.com/mods/
##############################################################
## Author Notes:
##    This MOD requires that mod_rewrite is enabled on your server and
##    supports .htaccess.
##
##    If your server doesn't support .htaccess you will need to add the
##    rewrite rules to your server configuration. I will not help you
##    do this. You will be on your own.
##
##    If you already have a .htaccess file in the main directory of your,
##    you will need to add the contents of the .htaccess file that is included
##    to your exsisting file.
##
##    If you don't have a .htaccess file in the main directory of your site
##    you will need to copy the one that is included with this MOD.
##
##############################################################
## MOD History:
##
##  2004-01-12 - Version 1.0.0
##   - First Release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################


#
#-----[ COPY ]------------------------------------------
#
# Only do if you don't already have a .htaccess file in the main directory
# of your site. See Author Notes for more information
#

copy .htaccess to .htaccess


#
#-----[ OPEN ]------------------------------------------
#
includes/page_header.php


#
#-----[ FIND ]------------------------------------------
#
# Note: this line has been shortened. The full line is
#    $template->set_filenames(array(
#        'overall_header' => ( empty($gen_simple_header) ) ? 'overall_header.tpl' : 'simple_header.tpl')
#    );
#
$template->set_filenames(array(
    'overall_header' =>
);

#
#-----[ AFTER, ADD ]------------------------------------------
#

ob_start();
function replace_mod_rewrite($s)
{
    $urlin = array(
        "'(?<!/)viewforum.php\?f=([0-9]*)&amp;topicdays=([0-9]*)&amp;start=([0-9]*)'",
        "'(?<!/)viewforum.php\?f=([0-9]*)&amp;mark=topics'",
        "'(?<!/)viewforum.php\?f=([0-9]*)'",

        "'(?<!/)viewtopic.php\?t=([0-9]*)&amp;view=previous'",
        "'(?<!/)viewtopic.php\?t=([0-9]*)&amp;view=next'",
        "'(?<!/)viewtopic.php\?t=([0-9]*)&amp;view=newest'",
        "'(?<!/)viewtopic.php\?t=([0-9]*)&amp;postdays=([0-9]*)&amp;postorder=([a-zA-Z]*)&amp;start=([0-9]*)'",        "'(?<!/)viewtopic.php\?t=([0-9]*)&amp;start=([0-9]*)&amp;postdays=([0-9]*)&amp;postorder=([a-zA-Z]*)&amp;highlight=([a-zA-Z0-9]*)'",
        "'(?<!/)viewtopic.php\?t=([0-9]*)&amp;start=([0-9]*)'",
        "'(?<!/)viewtopic.php\?t=([0-9]*)'",
        "'(?<!/)viewtopic.php\?p=([0-9]*)'");

    $urlout = array(
        "viewforum\\1-\\2-\\3.php",
        "mforum\\1.php",
        "forum\\1.php",

        "ptopic\\1.php",
        "ntopic\\1.php",
        "newtopic\\1.php",
        "ftopic\\1-\\2-\\3-\\4.php",
        "ftopic\\1-\\2-\\3-\\4-\\5.php",
        "ftopic\\1-\\2.php",
        "ftopic\\1.php",
        "sutra\\1.php");

    $s = preg_replace($urlin, $urlout, $s);

    return $s;
}

#
#-----[ OPEN ]------------------------------------------
#
includes/page_tail.php

#
#-----[ FIND ]------------------------------------------
#
$db->sql_close();

#
#-----[ AFTER, ADD ]------------------------------------------
#

$contents = ob_get_contents();
ob_end_clean();
echo replace_mod_rewrite($contents);
global $dbg_starttime;


#
#-----[ FIND ]------------------------------------------
#
    $gzip_contents = ob_get_contents();
    ob_end_clean();

#
#-----[ AFTER, ADD ]------------------------------------------
#

    
    echo replace_for_mod_rewrite($contents);
    global $dbg_starttime;

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM
  1. ##############################################################
  2. ## MOD Title: mod_rewrite
  3. ## MOD Author: wGEric < eric@egcnetwork.com > (Eric Faerber) http://eric.best-1.biz
  4. ## MOD Description: Use mod_rewrite on your board. It converts your dynamic links to something
  5. ##          more Search Engine Friendly
  6. ## MOD Version: 1.0.0
  7. ##
  8. ## Installation Level: Easy/
  9. ## Installation Time: 10 Minutes
  10. ## Files To Edit: includes/page_header.php
  11. ##         includes/page_footer.php
  12. ##         .htaccess (may need to)
  13. ## Included Files: .htaccess (may need to use)
  14. ##############################################################
  15. ## For Security Purposes, Please Check: http://www.phpbb.com/mods/ for the
  16. ## latest version of this MOD. Downloading this MOD from other sites could cause malicious code
  17. ## to enter into your phpBB Forum. As such, phpBB will not offer support for MOD's not offered
  18. ## in our MOD-Database, located at: http://www.phpbb.com/mods/
  19. ##############################################################
  20. ## Author Notes:
  21. ##    This MOD requires that mod_rewrite is enabled on your server and
  22. ##    supports .htaccess.
  23. ##
  24. ##    If your server doesn't support .htaccess you will need to add the
  25. ##    rewrite rules to your server configuration. I will not help you
  26. ##    do this. You will be on your own.
  27. ##
  28. ##    If you already have a .htaccess file in the main directory of your,
  29. ##    you will need to add the contents of the .htaccess file that is included
  30. ##    to your exsisting file.
  31. ##
  32. ##    If you don't have a .htaccess file in the main directory of your site
  33. ##    you will need to copy the one that is included with this MOD.
  34. ##
  35. ##############################################################
  36. ## MOD History:
  37. ##
  38. ##  2004-01-12 - Version 1.0.0
  39. ##   - First Release
  40. ##
  41. ##############################################################
  42. ## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
  43. ##############################################################
  44. #
  45. #-----[ COPY ]------------------------------------------
  46. #
  47. # Only do if you don't already have a .htaccess file in the main directory
  48. # of your site. See Author Notes for more information
  49. #
  50. copy .htaccess to .htaccess
  51. #
  52. #-----[ OPEN ]------------------------------------------
  53. #
  54. includes/page_header.php
  55. #
  56. #-----[ FIND ]------------------------------------------
  57. #
  58. # Note: this line has been shortened. The full line is
  59. #    $template->set_filenames(array(
  60. #        'overall_header' => ( empty($gen_simple_header) ) ? 'overall_header.tpl' : 'simple_header.tpl')
  61. #    );
  62. #
  63. $template->set_filenames(array(
  64.     'overall_header' =>
  65. );
  66. #
  67. #-----[ AFTER, ADD ]------------------------------------------
  68. #
  69. ob_start();
  70. function replace_mod_rewrite($s)
  71. {
  72.     $urlin = array(
  73.         "'(?<!/)viewforum.php\?f=([0-9]*)&amp;topicdays=([0-9]*)&amp;start=([0-9]*)'",
  74.         "'(?<!/)viewforum.php\?f=([0-9]*)&amp;mark=topics'",
  75.         "'(?<!/)viewforum.php\?f=([0-9]*)'",
  76.         "'(?<!/)viewtopic.php\?t=([0-9]*)&amp;view=previous'",
  77.         "'(?<!/)viewtopic.php\?t=([0-9]*)&amp;view=next'",
  78.         "'(?<!/)viewtopic.php\?t=([0-9]*)&amp;view=newest'",
  79.         "'(?<!/)viewtopic.php\?t=([0-9]*)&amp;postdays=([0-9]*)&amp;postorder=([a-zA-Z]*)&amp;start=([0-9]*)'",        "'(?<!/)viewtopic.php\?t=([0-9]*)&amp;start=([0-9]*)&amp;postdays=([0-9]*)&amp;postorder=([a-zA-Z]*)&amp;highlight=([a-zA-Z0-9]*)'",
  80.         "'(?<!/)viewtopic.php\?t=([0-9]*)&amp;start=([0-9]*)'",
  81.         "'(?<!/)viewtopic.php\?t=([0-9]*)'",
  82.         "'(?<!/)viewtopic.php\?p=([0-9]*)'");
  83.     $urlout = array(
  84.         "viewforum\\1-\\2-\\3.php",
  85.         "mforum\\1.php",
  86.         "forum\\1.php",
  87.         "ptopic\\1.php",
  88.         "ntopic\\1.php",
  89.         "newtopic\\1.php",
  90.         "ftopic\\1-\\2-\\3-\\4.php",
  91.         "ftopic\\1-\\2-\\3-\\4-\\5.php",
  92.         "ftopic\\1-\\2.php",
  93.         "ftopic\\1.php",
  94.         "sutra\\1.php");
  95.     $s = preg_replace($urlin, $urlout, $s);
  96.     return $s;
  97. }
  98. #
  99. #-----[ OPEN ]------------------------------------------
  100. #
  101. includes/page_tail.php
  102. #
  103. #-----[ FIND ]------------------------------------------
  104. #
  105. $db->sql_close();
  106. #
  107. #-----[ AFTER, ADD ]------------------------------------------
  108. #
  109. $contents = ob_get_contents();
  110. ob_end_clean();
  111. echo replace_mod_rewrite($contents);
  112. global $dbg_starttime;
  113. #
  114. #-----[ FIND ]------------------------------------------
  115. #
  116.     $gzip_contents = ob_get_contents();
  117.     ob_end_clean();
  118. #
  119. #-----[ AFTER, ADD ]------------------------------------------
  120. #
  121.     
  122.     echo replace_for_mod_rewrite($contents);
  123.     global $dbg_starttime;
  124. #
  125. #-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
  126. #
  127. # EoM


The .HTACCESS file is as follows:

Code: [ Select ]
RewriteEngine On
RewriteRule ^forums.* /index.php


RewriteRule ^viewforum([0-9]*)-([0-9]*)-([0-9]*).* /viewforum.php?f=$1&topicdays=$2&start=$3
RewriteRule ^mforum([0-9]*).* /viewforum.php?f=$1&mark=topic
RewriteRule ^forum([0-9]*).* /viewforum.php?f=$1

RewriteRule ^ptopic([0-9]*).* /viewtopic.php?t=$1&view=previous
RewriteRule ^ntopic([0-9]*).* /viewtopic.php?t=$1&view=next
RewriteRule ^newtopic([0-9]*).* /viewtopic.php?t=$1&view=newest
RewriteRule ^ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* /viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4
RewriteRule ^ftopic([0-9]*)-([0-9]*)-([0-9]*)-([a-zA-Z]*)-([a-zA-Z]*).* /viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5
RewriteRule ^ftopic([0-9]*)-([0-9]*).* /viewtopic.php?t=$1&start=$2
RewriteRule ^ftopic([0-9]*).* /viewtopic.php?t=$1
RewriteRule ^sutra([0-9]*).* /viewtopic.php?p=$1
  1. RewriteEngine On
  2. RewriteRule ^forums.* /index.php
  3. RewriteRule ^viewforum([0-9]*)-([0-9]*)-([0-9]*).* /viewforum.php?f=$1&topicdays=$2&start=$3
  4. RewriteRule ^mforum([0-9]*).* /viewforum.php?f=$1&mark=topic
  5. RewriteRule ^forum([0-9]*).* /viewforum.php?f=$1
  6. RewriteRule ^ptopic([0-9]*).* /viewtopic.php?t=$1&view=previous
  7. RewriteRule ^ntopic([0-9]*).* /viewtopic.php?t=$1&view=next
  8. RewriteRule ^newtopic([0-9]*).* /viewtopic.php?t=$1&view=newest
  9. RewriteRule ^ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*).* /viewtopic.php?t=$1&postdays=$2&postorder=$3&start=$4
  10. RewriteRule ^ftopic([0-9]*)-([0-9]*)-([0-9]*)-([a-zA-Z]*)-([a-zA-Z]*).* /viewtopic.php?t=$1&start=$2&postdays=$3&postorder=$4&highlight=$5
  11. RewriteRule ^ftopic([0-9]*)-([0-9]*).* /viewtopic.php?t=$1&start=$2
  12. RewriteRule ^ftopic([0-9]*).* /viewtopic.php?t=$1
  13. RewriteRule ^sutra([0-9]*).* /viewtopic.php?p=$1


if you want to examine to modded files, i'd gladly show you
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

the file is .htacces, not .HTACCESS.

As Linux is a case sensitive operating system, if your file is indeed named .HTACCESS, that could be your problem.
  • silentdreamer
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: Trapped in the mist of dark desires...

Post 3+ Months Ago

nope, thats not it. my .htaccess file is named properly.
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

Are your paths correct?

If your forum is installed in a subdirectory, such as http://www.yoursite.com/forum then linking to /viewforum.php?f=$1 won't work. You'd have to use /forum/viewforum.php?f=$1 to get your paths correct.
  • silentdreamer
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: Trapped in the mist of dark desires...

Post 3+ Months Ago

its installed in the main directory
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

in fact, your best bet would not be using paths at all...

Just link to viewforum.php?f=$1 instead of /viewforum.php?f=$1

What's the URL?
  • silentdreamer
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: Trapped in the mist of dark desires...

Post 3+ Months Ago

for now (since my domain names arent properly set up yet), the url to the forum is

http://www.myprohost.com/~rpgcat

this will take you right to the forum (I have removed all the Mod Rewrites on my forum after having those pages not found)
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

Ok, here's the thing...

it is your paths...

you're pointing to /viewforum.php

But it's not :)

The URL in this case is /~rpgcat/viewforum.php

If you remove it so that it's just viewforum.php (without the / at the beginning) the paths will be relative, and not absolute. Then it should work regardless of the location.
  • Axe
  • Genius
  • Genius
  • User avatar
  • Posts: 5739
  • Loc: Sub-level 28

Post 3+ Months Ago

Actually, my mod_rewrite isn't working through my ~user URLs either, but it does work through my actual site's domain name.

Given that http://www.myprohost.com is their primary domain name, I'm guessing they've disabled mod_rewrite overrides for that domain.
  • silentdreamer
  • Beginner
  • Beginner
  • User avatar
  • Posts: 61
  • Loc: Trapped in the mist of dark desires...

Post 3+ Months Ago

well, guess i have to wait for my domain name to be fully set up before i do Mod_Rewrite again.

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 151 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.