Sida 1 av 2

Fundering kring htaccess filen

Postat: 2006-03-04 15:15
av WickeD
Hej!

jag håller på att jhjälpa en komis att installera en Plus portal, och jag har kört fast ´med denna fil:

htaccess:

Jag vill att man ska komma till portal.php istället för index.php när man kommer till sidan.
Hur skriver jag i denna fil då? och är det något med i denna fil jag behöver ändra innan jag lägger in den?

Kod: Markera allt


DirectoryIndex index.html index.htm portal.php index.php

############################################################

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} ^(.*)echr(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)esystem(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)union(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)UNION(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)alert\(document(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)SQL_INJECTION(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)wget\%20
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]

#########################################################
# Mod Rewrite Rules for Static URLs can be found in this file.
#
# You have to set the correct Path to your Forum here otherwise this will not work !
# Just change the "YOUR_PATH" in the below code to the path your Forum uses.
# For example if your Forum can be reached at http://www.myforum.com/phpBB2/ you have
# to set the path to this
#
# RewriteRule (.*) /phpBB2/index.php [L]
#                   ^^^^^^
#
# If your Forum can be reached at http://www.myforum.com you can delete the path part
# 
# RewriteRule (.*) /index.php [L]
#
# After making all needed changes in this file rename it to .htaccess and delete the original
# .htaccess file
############################################################


RewriteCond %{REQUEST_FILENAME} /forums.html
RewriteRule (.*) /phpBB2/index.php [L]

RewriteCond %{REQUEST_FILENAME} /forumc([0-9]*).*
RewriteRule (.*) /phpBB2/index.php?c=%1 [L]

RewriteCond %{REQUEST_FILENAME} /forumc([0-9]*),(.*).html
RewriteRule (.*) /phpBB2/index.php?c=%1 [L]

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

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

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

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

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

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

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

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

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

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

RewriteCond %{REQUEST_FILENAME} /ftopic([0-9]*).html
RewriteRule (.*) /phpBB2/viewtopic.php?t=%1&start=%2&postdays=%3&postorder=%4&highlight=%5 [L]

Postat: 2006-03-04 15:27
av Holger
Detta styr i vilken ordningsföljd filerna anropas:

Kod: Markera allt

DirectoryIndex index.html index.htm portal.php index.php

Postat: 2006-03-04 15:31
av WickeD
Ska jag bara ändra till:

Kod: Markera allt

DirectoryIndex portal.php index.html index.htm index.php
Eller ska jag ändra något i resten av filen också?

Postat: 2006-03-04 15:32
av Holger
Lägg in det överst i .htaccess-filen

Postat: 2006-03-04 15:37
av WickeD
Det ser ut så här i den filen nu:

Är det rätt?

Kod: Markera allt

DirectoryIndex portal.php index.html index.htm index.php

############################################################

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} ^(.*)echr(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)esystem(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)union(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)UNION(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)alert\(document(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)SQL_INJECTION(.*) [OR]
RewriteCond %{QUERY_STRING} ^(.*)wget\%20
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]

#########################################################
# Mod Rewrite Rules for Static URLs can be found in this file.
#
# You have to set the correct Path to your Forum here otherwise this will not work !
# Just change the "YOUR_PATH" in the below code to the path your Forum uses.
# For example if your Forum can be reached at http://www.myforum.com/phpBB2/ you have
# to set the path to this
#
# RewriteRule (.*) /phpBB2/index.php [L]
#                   ^^^^^^
#
# If your Forum can be reached at http://www.myforum.com you can delete the path part
# 
# RewriteRule (.*) /index.php [L]
#
# After making all needed changes in this file rename it to .htaccess and delete the original
# .htaccess file
############################################################


RewriteCond %{REQUEST_FILENAME} /forums.html
RewriteRule (.*) /phpBB2/index.php [L]

RewriteCond %{REQUEST_FILENAME} /forumc([0-9]*).*
RewriteRule (.*) /phpBB2/index.php?c=%1 [L]

RewriteCond %{REQUEST_FILENAME} /forumc([0-9]*),(.*).html
RewriteRule (.*) /phpBB2/index.php?c=%1 [L]

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

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

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

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

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

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

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

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

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

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

RewriteCond %{REQUEST_FILENAME} /ftopic([0-9]*).html
RewriteRule (.*) /phpBB2/viewtopic.php?t=%1&start=%2&postdays=%3&postorder=%4&highlight=%5 [L]

Postat: 2006-03-04 15:38
av Holger
hm, det kan jag inte svara på, men prova en gång. Jag vet inte om b-one stöder rewrite!

Postat: 2006-03-04 15:40
av WickeD
Det verkar inte så, för jag kommer fortfarande till forumet när jag går in på sidan.

Kan jag inte ta bort denna fil och göra en egen?

Och hur ska den se ut i så fall?

Postat: 2006-03-04 15:42
av Holger
Lägg upp en fil som bara innehåller det som jag skrev ovan ...

Postat: 2006-03-04 15:48
av WickeD
Jag la in en file med innehållet:

Kod: Markera allt

DirectoryIndex portal.php index.html index.htm index.php
Men jag kommer inte till portal.php ändå.

Skumt!

Postat: 2006-03-04 15:49
av Holger
VAR la du filen?
Direkt i forum-rooten måste den ligga! Dessutom är PUNKTEN i .htaccess viktig!

Postat: 2006-03-04 15:51
av WickeD
Jag la den direkt i ROOT.

Sedan så la jag in den utan en punkt.
och la till punkten efter att jag hade laddat upp den med FTP´n

Postat: 2006-03-04 15:53
av Holger
Precis riktigt.

Vilket webbhotell? Inte alla stöder egna htaccess-filer!

Postat: 2006-03-04 16:00
av WickeD
Det är på ett ganska nytt och mindre webhotell.

Detta är det: http://www.serv.se


Ja det vet jag ju inte om dom stödjer.

Men i min file står det:

Kod: Markera allt

DirectoryIndex index.html index.htm portal.php index.php
Och man kommer till portalen när man går in på sidan.
Undrar om det är någon annan inställning.

Om du undrar så är det denna sidan jag hjälper han med: http://baltazar.hundserver.com

Postat: 2006-03-04 16:07
av Holger
Nej, det är ingen annan inställning. Det är precis

Kod: Markera allt

DirectoryIndex index.html index.htm portal.php index.php
som gör att portalen visas först på din sajt!

Postat: 2006-03-04 16:27
av WickeD
Jag pratade med Admin på http://www.serv.se och han la om adressen så det fungerar nu.

Tack för hjälpen Holger!
Ha de bra!
//Micke