Seite 1 von 1

Mod Rewrite: Fehler 403 forbidden

Verfasst: 15.04.2005 10:23
von langerxxx
Hallo zusammen,

ich bin gerade auf phpbb umgestiegen. Für die SuMa-Optimierung möchte ich gerne Mod Rewrite nutzen. Dazu habe ich den Code von larsneo in meine .htaccess-Datei eingefügt und entsprechend angepasst.

Allerdings bekomme ich jetzt auf der kompletten Domain ein "Forbidden
You don't have permission to access /index.php on this server.".

Das Forum liegt direkt im Hauptverzeichnis, .htaccess-Dateien sind erlaubt und laut phpinfo() ist mod_rewrite installiert.

Hat jemand eine Idee, woran das liegen könnte? Normalerweise sollten ja auch ohne die Änderungen am PHPBB-Code die Seiten weiterhin per normaler URL erreichbar, oder?

Unten der Code aus meiner .htaccess:

Code: Alles auswählen

RewriteEngine On 

# prevent access from santy webworm a-e 
RewriteCond %{QUERY_STRING} ^(.*)highlight=\%2527 [OR] 
RewriteCond %{QUERY_STRING} ^(.*)rush=\%65\%63\%68 [OR] 
RewriteCond %{QUERY_STRING} ^(.*)rush=echo [OR] 
RewriteCond %{QUERY_STRING} ^(.*)wget\%20 [OR] 
RewriteCond %{QUERY_STRING} ^(.*)cmd= 
RewriteRule ^.*$ http://127.0.0.1/ [R,L] 

# prevent pre php 4.3.10 bug
RewriteCond %{HTTP_COOKIE}% s:(.*):\%22test1\%22\%3b 
RewriteRule ^.*$ http://127.0.0.1/ [R,L] 

# prevent perl user agent (most often used by santy) 
RewriteCond %{HTTP_USER_AGENT} ^lwp.* [NC] 
RewriteRule ^.*$ http://127.0.0.1/ [R,L] 

# extended rewriting only for .html [thx to Caterham] 
RewriteRule !\.html$ - [L] 

# Short URL implementation [larsneo] 
RewriteCond %{REQUEST_URI} ^/forums\.html
RewriteRule (.*) /index.php [R=301,L] 

RewriteCond %{REQUEST_URI} ^/index-mark\.html 
RewriteRule (.*) /index.php?mark=forums [L] 

RewriteCond %{REQUEST_URI} ^/index\.html 
RewriteRule (.*) /index.php [L] 

RewriteCond %{REQUEST_URI} ^/category([0-9]*)\.html 
RewriteRule (.*) /index.php?c=%1 [L] 

RewriteCond %{REQUEST_URI} ^/forum([0-9]*)-([0-9]*)-([0-9]*)\.html  
RewriteRule (.*) /viewforum.php?f=%1&topicdays=%2&start=%3 [L] 

RewriteCond %{REQUEST_URI} ^/forum([0-9]*)-([0-9]*)\.html  
RewriteRule (.*) /viewforum.php?f=%1&start=%2 [L] 

RewriteCond %{REQUEST_URI} ^/forum([0-9]*)-mark\.html 
RewriteRule (.*) /viewforum.php?f=%1&mark=topics [L] 

RewriteCond %{REQUEST_URI} ^/forum([0-9]*)\.html 
RewriteRule (.*) /viewforum.php?f=%1 [L] 

RewriteCond %{REQUEST_URI} ^/ptopic([0-9]*)\.html 
RewriteRule (.*) /viewtopic.php?t=%1&view=previous [L] 

RewriteCond %{REQUEST_URI} ^/ntopic([0-9]*)\.html 
RewriteRule (.*) /viewtopic.php?t=%1&view=next [L] 

RewriteCond %{REQUEST_URI} ^/ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*)-([a-zA-Z0-9]*)\.html 
RewriteRule (.*) /viewtopic.php?t=%1&start=%2&postdays=%3&postorder=%4&highlight=%5 [L] 

RewriteCond %{REQUEST_URI} ^/ftopic([0-9]*)-([0-9]*)-([a-zA-Z]*)-([0-9]*)\.html 
RewriteRule (.*) /viewtopic.php?t=%1&postdays=%2&postorder=%3&start=%4 [L] 

RewriteCond %{REQUEST_URI} ^/ftopic([0-9]*)-([0-9]*)\.html 
RewriteRule (.*) /viewtopic.php?t=%1&start=%2 [L] 

RewriteCond %{REQUEST_URI} ^/ftopic([0-9]*)\.html 
RewriteRule (.*) /viewtopic.php?t=%1 [L] 

RewriteCond %{REQUEST_URI} ^/fpost([0-9]*)\.html 
RewriteRule (.*) /viewtopic.php?p=%1 [L] 

RewriteCond %{REQUEST_URI} ^/post-newtopic-([0-9]*)\.html 
RewriteRule (.*) /posting.php?mode=newtopic&f=%1 [L] 

RewriteCond %{REQUEST_URI} ^/post-reply-([0-9]*)\.html 
RewriteRule (.*) /posting.php?mode=reply&t=%1 [L] 

RewriteCond %{REQUEST_URI} ^/post-([a-z]*)-([0-9]*)\.html 
RewriteRule (.*) /posting.php?mode=%1&p=%2 [L] 

RewriteCond %{REQUEST_URI} ^/album\.html 
RewriteRule (.*) /album.php [L] 

RewriteCond %{REQUEST_URI} ^/albumpic([0-9]*)-([a-z]*)\.html 
RewriteRule (.*) /album_page.php?pic_id=%1&mode=%2 [L] 

RewriteCond %{REQUEST_URI} ^/albumpic([0-9]*)\.html 
RewriteRule (.*) /album_page.php?pic_id=%1 [L] 

RewriteCond %{REQUEST_URI} ^/palbum\.html 
RewriteRule (.*) /album_personal_index.php [L] 

RewriteCond %{REQUEST_URI} ^/palbum([0-9]*)\.html 
RewriteRule (.*) /album_personal.php?user_id=%1 [L] 

RewriteCond %{REQUEST_URI} ^/profile([0-9]*)\.html 
RewriteRule (.*) /profile.php\?mode=viewprofile&u=%1 [L] 

RewriteCond %{REQUEST_URI} ^/search-author-(.*)\.html 
RewriteRule (.*) /search.php\?search_author=%1 [L] 

RewriteCond %{REQUEST_URI} ^/search-([0-9]*)-([0-9]*)\.html 
RewriteRule (.*) /search.php\?search_id=%1&start=%2 [L] 

RewriteCond %{REQUEST_URI} ^/search-([a-zA-Z]*)\.html 
RewriteRule (.*) /search.php\?search_id=%1 [L] 

RewriteCond %{REQUEST_URI} ^/privmsg-([a-zA-Z]*)-([0-9]*)\.html 
RewriteRule (.*) /privmsg.php\?mode=%1&u=%2 [L] 

RewriteCond %{REQUEST_URI} ^/privmsg-([a-zA-Z]*)\.html 
RewriteRule (.*) /privmsg.php\?folder=%1 [L] 

RewriteCond %{REQUEST_URI} ^/register\.html 
RewriteRule (.*) /profile.php\?mode=register&agreed=true [L] 

RewriteCond %{REQUEST_URI} ^/profile-([a-zA-Z0-9]*)\.html 
RewriteRule (.*) /profile.php\?mode=%1 [L] 

RewriteCond %{REQUEST_URI} ^/map-([0-9]*)\.html 
RewriteRule (.*) /map.php\?highlight=%1 [L] 

RewriteCond %{REQUEST_URI} ^/map\.html 
RewriteRule (.*) /map.php [L] 

RewriteCond %{REQUEST_URI} ^/faq\.html 
RewriteRule (.*) /faq.php [L] 

RewriteCond %{REQUEST_URI} ^/search\.html 
RewriteRule (.*) /search.php [L] 

RewriteCond %{REQUEST_URI} ^/memberlist\.html 
RewriteRule (.*) /memberlist.php [L] 

RewriteCond %{REQUEST_URI} ^/groups\.html 
RewriteRule (.*) /groupcp.php [L] 

RewriteCond %{REQUEST_URI} ^/report\.html 
RewriteRule (.*) /report.php [L] 

RewriteCond %{REQUEST_URI} ^/online\.html 
RewriteRule (.*) /viewonline.php [L]
Vielen Dank schonmal im voraus. Ich weiß mir momentan echt keinen Rat mehr.

Viele Grüße
Dan

Verfasst: 15.04.2005 10:26
von Mario Siebert
Hast du auch die page_header.php entsprechend angepasst?

Grüße Mario

Verfasst: 15.04.2005 10:29
von -Jo-
Mario Siebert hat geschrieben:Hast du auch die page_header.php entsprechend angepasst?

Grüße Mario
Das heißt?

Wie muss sie denn angepasst werden?

Gruß,
Jo.

Verfasst: 15.04.2005 10:37
von Mario Siebert
So:

page_header.php

[suchen]

Code: Alles auswählen

// 
// Generate logged in/logged out status 
//
[Darüber einfügen]

Code: Alles auswählen

// 
// start Short URL implementation [larsneo] 
// 
// start buffering 
ob_start(); 

function replace_for_mod_rewrite(&$s) { 
// get the correct base_url: protocoll,url,path to make sure to rewrite only internal links 
if (empty($HTTP_SERVER_VARS['HTTP_HOST'])) { 
   $server = getenv('HTTP_HOST'); 
} else { 
   $server = $HTTP_SERVER_VARS['HTTP_HOST']; 
} 
// IIS sets HTTPS=off 
if (isset($HTTP_SERVER_VARS['HTTPS']) && $HTTP_SERVER_VARS['HTTPS'] != 'off') { 
   $proto = 'https://'; 
} else { 
   $proto = 'http://'; 
} 
// Get the name of this URI 
// Start of with REQUEST_URI 
if (isset($HTTP_SERVER_VARS['REQUEST_URI'])) { 
   $path = $HTTP_SERVER_VARS['REQUEST_URI']; 
} else { 
   $path = getenv('REQUEST_URI'); 
} 
if ((empty($path)) || (substr($path, -1, 1) == '/')) { 
   // REQUEST_URI was empty or pointed to a path 
   // Try looking at PATH_INFO 
   $path = getenv('PATH_INFO'); 
   if (empty($path)) { 
      // No luck there either 
      // Try SCRIPT_NAME 
      if (isset($HTTP_SERVER_VARS['SCRIPT_NAME'])) { 
         $path = $HTTP_SERVER_VARS['SCRIPT_NAME']; 
      } else { 
         $path = getenv('SCRIPT_NAME'); 
      } 
   } 
} 

$path = preg_replace('/[#\?].*/', '', $path); 
$path = dirname($path); 

if (preg_match('!^[/\\\]*$!', $path)) { 
   $path = ''; 
} 

$base_url = "$proto$server$path/"; 
$prefix = '|"(?:'.$base_url.')?'; 
// now that we know about the correct $prefix we can start the rewriting 

$urlin = 
array( 
$prefix . '(?<!/)index.php\?mark=forums"|', 
$prefix . '(?<!/)index.php"|', 
$prefix . '(?<!/)index.php\?c=([0-9]*)"|', 
$prefix . '(?<!/)viewforum.php\?f=([0-9]*)&(?:amp;)topicdays=0&(?:amp;)start=0"|', 
$prefix . '(?<!/)viewforum.php\?f=([0-9]*)&(?:amp;)topicdays=0&(?:amp;)start=([0-9]*)"|', 
$prefix . '(?<!/)viewforum.php\?f=([0-9]*)&(?:amp;)topicdays=([0-9]*)&(?:amp;)start=([0-9]*)"|', 
$prefix . '(?<!/)viewforum.php\?f=([0-9]*)&(?:amp;)mark=topics"|', 
$prefix . '(?<!/)viewforum.php\?f=([0-9]*)"|', 
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)highlight="|', 
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)view=previous"|', 
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)view=next"|', 
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)start=([0-9]*)&(?:amp;)postdays=([0-9]*)&(?:amp;)postorder=([a-zA-Z]*)&(?:amp;)highlight=([a-zA-Z0-9]*)"|', 
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)postdays=0&(?:amp;)postorder=asc&(?:amp;)start=0"|', 
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)postdays=0&(?:amp;)postorder=asc&(?:amp;)start=([0-9]*)"|', 
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)postdays=([0-9]*)&(?:amp;)postorder=([a-zA-Z]*)&(?:amp;)start=([0-9]*)"|', 
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)start=0"|', 
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)&(?:amp;)start=([0-9]*)"|', 
$prefix . '(?<!/)viewtopic.php\?t=([0-9]*)"|', 
$prefix . '(?<!/)viewtopic.php\?p=([0-9]*)&(?:amp;)highlight=#([0-9]*)"|', 
$prefix . '(?<!/)viewtopic.php\?p=([0-9]*)#([0-9]*)"|', 
$prefix . '(?<!/)posting.php\?mode=newtopic&(?:amp;)f=([0-9]*)"|', 
$prefix . '(?<!/)posting.php\?mode=reply&(?:amp;)t=([0-9]*)"|', 
$prefix . '(?<!/)posting.php\?mode=([a-z]*)&(?:amp;)p=([0-9]*)"|', 
$prefix . '(?<!/)album.php"|', 
$prefix . '(?<!/)album_personal_index.php"|', 
$prefix . '(?<!/)album_personal.php\?user_id=([0-9]*)"|', 
$prefix . '(?<!/)profile.php\?mode=viewprofile&(?:amp;)u=([0-9]*)"|', 
$prefix . '(?<!/)search.php\?search_author=([[:alnum:]%+\.]+)"|', 
$prefix . '(?<!/)search.php\?search_id=([0-9]*)&(?:amp;)start=([0-9]*)"|', 
$prefix . '(?<!/)search.php\?search_id=([a-zA-Z]*)"|', 
$prefix . '(?<!/)privmsg.php\?mode=([a-zA-Z]*)&(?:amp;)u=([0-9]*)"|', 
$prefix . '(?<!/)privmsg.php\?folder=([a-zA-Z]*)"|', 
$prefix . '(?<!/)profile.php\?mode=register&(?:amp;)agreed=true"|', 
$prefix . '(?<!/)profile.php\?mode=([0-9a-zA-Z]*)"|', 
$prefix . '(?<!/)map.php\?highlight=([0-9]*)"|', 
$prefix . '(?<!/)map.php"|', 
$prefix . '(?<!/)faq.php"|', 
$prefix . '(?<!/)search.php"|', 
$prefix . '(?<!/)memberlist.php"|', 
$prefix . '(?<!/)groupcp.php"|', 
$prefix . '(?<!/)report.php"|', 
$prefix . '(?<!/)viewonline.php"|', 
); 
$urlout = array( 
'"index-mark.html"', 
'"index.html"', 
'"category\\1.html"', 
'"forum\\1.html"', 
'"forum\\1-\\2.html"', 
'"forum\\1-\\2-\\3.html"', 
'"forum\\1-mark.html"', 
'"forum\\1.html"', 
'"ftopic\\1.html"', 
'"ptopic\\1.html"', 
'"ntopic\\1.html"', 
'"ftopic\\1.html"', 
'"ftopic\\1.html"', 
'"ftopic\\1-\\2.html"', 
'"ftopic\\1-\\2-\\3-\\4.html"', 
'"ftopic\\1.html"', 
'"ftopic\\1-\\2.html"', 
'"ftopic\\1.html"', 
'"fpost\\1.html#\\2"', 
'"fpost\\1.html#\\2"', 
'"post-newtopic-\\1.html"', 
'"post-reply-\\1.html"', 
'"post-\\1-\\2.html"', 
'"album.html"', 
'"palbum.html"', 
'"palbum\\1.html"', 
'"profile\\1.html"', 
'"search-author-\\1.html"', 
'"search-\\1-\\2.html"', 
'"search-\\1.html"', 
'"privmsg-\\1-\\2.html"', 
'"privmsg-\\1.html"', 
'"register.html"', 
'"profile-\\1.html"', 
'"map-\\1.html"', 
'"map.html"', 
'"faq.html"', 
'"search.html"', 
'"memberlist.html"', 
'"groups.html"', 
'"report.html"', 
'"online.html"', 
); 

$s = preg_replace($urlin, $urlout, $s); 
return $s; 
} 
// 
// end Short URL implementation [larsneo] 
//

zusätzlich natürlich noch die Anpassungen aus dem Original Topic für die page_tail.php: http://www.phpbb.de/viewtopic.php?t=44090

Grüße Mario

Verfasst: 15.04.2005 10:39
von -Jo-
Danke! :grin:

Verfasst: 15.04.2005 11:36
von larsneo
Allerdings bekomme ich jetzt auf der kompletten Domain ein "Forbidden
You don't have permission to access /index.php on this server.".
provider fragen.

Verfasst: 15.04.2005 18:15
von langerxxx
Hallo,

ja, die Änderungen an den PHP-Dateien habe ich eingebaut. Noch jemand eine Idee, woher die Fehlermeldung kommen könnte?