Runar Skrevet 12. juni 2008 Del Skrevet 12. juni 2008 God kveld, godtfolk! Jeg beklager hvis dette er feil forum, men jeg fant flere andre tråder som omhandlet htaccess her ved et søk. Uansett, jeg har nå greid å opparbeide meg en .htaccess-fil på 165 linjer, noe som kanskje er litt for mye. Jeg aktiverte RewriteLog i httpd.conf og resultatet var ikke akkurat betryggende. Jeg lurte derfor på om det var noen her som kan litt mer om mod_rewrite og lignende enn meg, som kanskje kunne hjelpe meg med å korte ned filen og sørge for at serveren ikke belastes like mye? .htaccess: Klikk for å se/fjerne innholdet nedenfor # compress all parsed PHP pages from current directory php_flag zlib.output_compression On # set compressing level value to 1 php_value zlib.output_compression_level 1 # turn off magic_quotes_gpc php_flag magic_quotes_gpc off # disable directory browsing Options All -Indexes # password for visitors AuthName "Restricted Area" AuthType Basic AuthUserFile /.htpasswd Require valid-user # allow access for webmaster and certain people Order Deny,Allow Deny from all Allow from localhost Allow from 192.168 Satisfy any # initialize and enable rewrite engine RewriteEngine On RewriteBase / # custom error pages ErrorDocument 403 /error.php ErrorDocument 404 /error.php # send Atom and RSS requests to the site docroot to be rewritten for ExpressionEngine RewriteRule .*rss.xml$ /feed/news.xml [R] # remove www from requested url if present RewriteCond %{HTTP_HOST} ^www\.domene\.info$ [NC] RewriteRule ^(.*)$ http://domene.info/$1 [R=301,L] # redirect domene.info/request to single files and remove backslash (/request/ -> /request) RewriteCond %{REQUEST_URI} !-f [NC] RewriteCond %{SCRIPT_FILENAME} \.(php)$ [NC] RewriteRule ^([a-z-]+)/$ /$1 [R] RewriteRule ^([a-z-]+)$ /$1.php [L] # make map images look like .png files RewriteRule ^images/maps/([a-z]+)/([a-z0-9-]+).png /locate.php?type=$1&locate=$2 # set experie header to 10 years on javascript and css files <FilesMatch "\.(js|css)$"> ExpiresActive On ExpiresDefault "access plus 10 years" </FilesMatch> # make css files look like a .css file RewriteRule ^style/screen.([0-9]+).css /style/style.php?version=$1 [L] # rule for versioned static (javascript) files RewriteRule ^(script|style)/(.+)\.(.+)\.(js|css)$ $1/$2.$4 [L] # news and article feeds RewriteRule ^feed/news.xml /feed.php?f=news [L] RewriteRule ^feed/articles.xml /feed.php?f=articles [L] # BETA TESTING - link section RewriteRule ^link/([a-z0-9]+)/$ /link/$1 [R] RewriteRule ^link/([a-z0-9]+)$ /link.php?url=$1 [L] # BETA TESTING # news RewriteRule ^news/([a-z0-9-]+)/([0-9]+)/$ /news/$1/$2 [R] RewriteRule ^news/([a-z0-9-]+)/([0-9]+)$ /news.php?title=$1&id=$2 [L] # archive sections RewriteRule ^archive/news/$ /archive/news [R] RewriteRule ^archive/news$ /archive.php?view=news [L] RewriteRule ^archive/articles/$ /archive/articles [R] RewriteRule ^archive/articles$ /archive.php?view=articles [L] # if article is not set, show the article archive RewriteRule ^articles/$ /archive/articles [R] RewriteRule ^articles$ /archive/articles [R] # ordinary articles section RewriteRule ^articles/([a-z0-9-]+)/$ /articles/$1 [R] RewriteRule ^articles/([a-z0-9-]+)$ /articles.php?title=$1&type=guide [L] # extended guides section RewriteRule ^guides/strategy-guide/$ /guides/strategy-guide [R] RewriteRule ^guides/strategy-guide$ /extended-articles.php?article=strategy-guide [L] RewriteRule ^guides/use-guides/$ /guides/strategy-guide [R] RewriteRule ^guides/use-guides$ /extended-articles.php?article=use-guides [L] RewriteRule ^guides/([a-z0-9-]+)/([a-z0-9-]+)/$ /guides/strategy-guide/$1/$2 [R] RewriteRule ^guides/([a-z0-9-]+)/([a-z0-9-]+)$ /extended-articles.php?article=$1&chapter=$2 [L] # ordinary guides section RewriteRule ^guides/([a-z0-9-]+)/$ /articles/$1 [R] RewriteRule ^guides/([a-z0-9-]+)$ /articles.php?title=$1&type=guide [L] # library sub sections RewriteRule ^library/([a-z-]+)/$ /library/$1 [R] RewriteRule ^library/([a-z-]+)$ /$1.php [L] # library creatures section RewriteRule ^library/creatures/difficulty-ratings/$ /library/creatures/difficulty-ratings [R] RewriteRule ^library/creatures/difficulty-ratings$ /difficulty-ratings.php [L] RewriteRule ^library/creatures/([a-zA-Z-]+)/$ /library/creatures/$1 [R] RewriteRule ^library/creatures/([a-zA-Z-]+)$ /creatures.php?creature=$1 # library npcs section RewriteRule ^library/npc/([a-zA-Z-]+)/$ /library/npc/$1 [R] RewriteRule ^library/npc/([a-zA-Z-]+)$ /npc.php?name=$1 [L] # library maps section RewriteRule ^library/maps/level-([0-9]+)/$ /library/maps/level-$1 [R] RewriteRule ^library/maps/level-([0-9]+)$ /maps.php?level=$1 [L] # library books section RewriteRule ^library/books-and-paperwork/([a-zA-Z0-9-]+)/$ /library/books-and-paperwork/$1 [R] RewriteRule ^library/books-and-paperwork/([a-zA-Z0-9-]+)$ /books-and-paperwork.php?title=$1 [L] # library locate (on map) section RewriteRule ^library/locate/([a-z0-9-]+)/$ /library/locate/$1 [R] RewriteRule ^library/locate/([a-z0-9-]+)$ /locate.php?locate=$1 [L] # library quests section RewriteRule ^library/quests/([a-z0-9-]+)/$ /library/quests/$1 [R] RewriteRule ^library/quests/([a-z0-9-]+)$ /quests.php?quest=$1 [L] RewriteRule ^library/quests/([a-z0-9-]+)/spoiler/$ /library/quests/$1/spoiler [R] RewriteRule ^library/quests/([a-z0-9-]+)/spoiler$ /quests.php?quest=$1&spoiler=true [L] # library items section RewriteRule ^library/items/([a-z-]+)/$ /library/items/$1 [R] RewriteRule ^library/items/([a-z-]+)$ /items.php?category=$1 [L] RewriteRule ^library/items/([a-z-]+)/([a-z-]+)/$ /library/items/$1/$2 [R] RewriteRule ^library/items/([a-z-]+)/([a-z-]+)$ /items.php?item=$2 [L] # view a poll (POST or GET) RewriteRule ^polls/view/$ /polls/view [R] RewriteRule ^polls/view$ /polls.php?mode=view RewriteRule ^polls/view/([0-9]+)/$ /polls/view/$1 [R] RewriteRule ^polls/view/([0-9]+)$ /polls.php?mode=view&id=$1 # vote on a poll (POST and GET) RewriteRule ^polls/vote/$ /polls/vote [R] RewriteRule ^polls/vote$ /polls.php?mode=vote RewriteRule ^polls/vote/([0-9]+)/$ /polls/vote/$1 [R] RewriteRule ^polls/vote/([0-9]+)$ /polls.php?mode=vote&id=1 # admin panel sub sections RewriteRule ^admin/([a-z-]+)/$ /admin/$1 [G] RewriteRule ^admin/([a-z-]+)$ /admin.php?mode=$1 [L] # admin panel edit sections RewriteRule ^admin/edit-([a-z]+)/([a-z-0-9]+)/$ /admin/edit-$1/$2 [R] RewriteRule ^admin/edit-([a-z]+)/([a-z-0-9]+)$ /admin.php?mode=edit-$1&id=$2 [L] # admin panel delete sections RewriteRule ^admin/delete-([a-z]+)/([a-z-0-9]+)/$ /admin/delete-$1/$2 [R] RewriteRule ^admin/delete-([a-z]+)/([a-z-0-9]+)$ /admin.php?mode=delete-$1&id=$2 [L] # admin panel validate article RewriteRule ^admin/validate-article/([0-9]+)/$ /admin/validate-article/$1 [R] RewriteRule ^admin/validate-article/([0-9]+)$ /admin.php?mode=validate-article&id=$1 [L] Jeg hadde tenkt til å poste loggfilen, men den var på 3544 linjer, noe jeg syns ble litt i overkant. Dette sier kanskje litt om at det er noe som burde ha vært gjort anderledes? Alle 3544 linjene er fra en sideoppdatering, ikke hopet seg opp over lengre tid. Takk for all hjelp, selv kritikk! Lenke til kommentar
Anbefalte innlegg
Opprett en konto eller logg inn for å kommentere
Du må være et medlem for å kunne skrive en kommentar
Opprett konto
Det er enkelt å melde seg inn for å starte en ny konto!
Start en kontoLogg inn
Har du allerede en konto? Logg inn her.
Logg inn nå