CUSTOMIZATION - About .htaccess Paths »  Show posts from    to     

Icy Phoenix


Documentation And How To - CUSTOMIZATION - About .htaccess Paths



Xusqui [ Wed 20 Sep, 2006 20:35 ]
Post subject: CUSTOMIZATION - About .htaccess Paths
Today I've benn looking inside the .htaccess just to try to learn how mod_rewrite works, and I found something:

I found these lines:

Code: [Hide]
  1. # STRICT CONDITION  
  2. #RewriteCond %{QUERY_STRING} ^.*(phpbb_root_path|album_root_path|module_root_path|mx_root_path|upi2db_file_path).*$  
  3. # LESS STRICT CONDITION  
  4. RewriteCond %{QUERY_STRING} ^.*(phpbb_root_path=|album_root_path=|module_root_path=|mx_root_path=|upi2db_file_path=).*$ 


So I figured out That I should replace all those paths with the ones in my web, isn't it?

And how should I fill it? I mean... As that .htaccess is in the root of my forum, phpbb_root_path should be "/", or "home/ka-tet-corp.com/data/htdocs/portal2.0"?

And which is the path to module_root and mx_root?

Thanks and sorry for such a dumb question !!!


KugeLSichA [ Wed 20 Sep, 2006 20:46 ]
Post subject: Re: About .htaccess paths!
Hi Xusqui,

to find out how mod_rewrite works, please take a look into that forum http://forum.modrewrite.com/

maybe this can help you...

cya


moreteavicar [ Fri 22 Sep, 2006 01:02 ]
Post subject: Re: About .htaccess paths!
No, you don't replace anything here. The condition is looking for you *edit... not neccessarily you but a hacker* trying to parse to the variables phpbb_root_path, album_root_path, module_root_path, mx_root_path and upi2db_file_path, these are actual variables in XS, and somebody might be trying to write to the query string yousite.com/somepage.php?mx_root_path=www.nasty.peoples.website.ru/nastyfile.php
The Query string means whatever is between ? and =

The syntax of .htaccess is nothing like php, but a wierd mix of pearl regex syntax, and some c++/php style boloean. I still don't understand it fully... and have to regularly resort to http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html

What MG has come up with here is nice and simple, yet completely failsafe (with one exception... if you don't have apache, or you do, but don't have mod rewrite!).


Xusqui [ Fri 22 Sep, 2006 16:27 ]
Post subject: Respuesta: About .htaccess paths!
Ok, Thnx moreteavicar!!!!

I'm an absolute dumb with .htaccess and mod_rewrite, so I didn't know what that line was for!!!

Thnx again!!


moreteavicar [ Sat 23 Sep, 2006 01:51 ]
Post subject: Re: About .htaccess paths!
You're welcome


Xusqui [ Sat 23 Sep, 2006 13:24 ]
Post subject: Respuesta: About .htaccess paths!
BTW, KugeLSichA, thank you very much for such a link... It really helped me to get what I wanted to... Now I got the website the way I like!!!


KugeLSichA [ Sun 24 Sep, 2006 01:13 ]
Post subject: Re: Respuesta: About .htaccess paths!
Xusqui wrote: [View Post]
BTW, KugeLSichA, thank you very much for such a link... It really helped me to get what I wanted to... Now I got the website the way I like!!!


you´re welcome!

nice to hear that you solved this


Mighty Gorgon [ Sun 01 Oct, 2006 21:11 ]
Post subject: Re: About .htaccess paths!
Xusqui, try to post here what you have done, so someone else should take advantage of it.

I'll move this post to Docs...


Xusqui [ Mon 02 Oct, 2006 00:42 ]
Post subject: Respuesta: About .htaccess paths!
Actually... I didn't change anything meaning I didn't change the code posted in the first topic... But...

1.- I had my site inside /portal/
2.- I moved my site inside /porta2.0/
3.- I wanted that every request to /portal/xxxx.xxx was redirected to /portal2.0/xxxx.xxx

so, inside /portal/ I created a .htaccess with the following code:

Code: [Hide] [Select]
Options +FollowSymLinks

RewriteEngine on
RewriteRule ^([a-zA-Z0-9]+).php$ /portal2.0/$1.php [R=301,L]

RewriteRule [.]*-vf([0-9]*) /portal2.0/viewforum.php?%{QUERY_STRING}&f=$1 [R=301,L]
RewriteRule [.]*-vp([0-9]*) /portal2.0/viewtopic.php?%{QUERY_STRING}&p=$1 [R=301,L]
RewriteRule [.]*-vt([0-9]*) /portal2.0/viewtopic.php?%{QUERY_STRING}&t=$1 [R=301,L]
RewriteRule [.]*-vf([0-9]*) /portal2.0/viewforum.php?%{QUERY_STRING}&f=$1 [R=301,L]
RewriteRule [.]*-vc([0-9]*) /portal2.0/forum.php?%{QUERY_STRING}&c=$1 [R=301,L]
RewriteRule [.]*-vc([0-9]*) /portal2.0/forum.php?%{QUERY_STRING}&c=$1 [R=301,L]
RewriteRule [.]*-ac([0-9]*) /portal2.0/album_cat.php?%{QUERY_STRING}&cat_id=$1 [R=301,L]
RewriteRule [.]*-at([0-9]*) /portal2.0/album_thumbnail.php?%{QUERY_STRING}&pic_id=$1 [R=301,L]
RewriteRule [.]*-apic([0-9]*) /portal2.0/album_pic.php?%{QUERY_STRING}&pic_id=$1 [R=301,L]
RewriteRule [.]*-apm([0-9]*) /portal2.0/album_picm.php?%{QUERY_STRING}&pic_id=$1 [R=301,L]
RewriteRule [.]*-full-asp([0-9]*) /portal2.0/album_showpage.php?full=&pic_id=$1 [R=301,L]
RewriteRule [.]*-asp([0-9]*) /portal2.0/album_showpage.php?%{QUERY_STRING}&pic_id=$1 [R=301,L]
RewriteRule [.]*-aper([0-9]*) /portal2.0/album_personal.php?%{QUERY_STRING}&user_id=$1 [R=301,L]
RewriteRule [.]*-dc([0-9]*) /portal2.0/dload.php?%{QUERY_STRING}action=category&cat_id=$1 [R=301,L]
RewriteRule [.]*-df([0-9]*) /portal2.0/dload.php?%{QUERY_STRING}action=file&file_id=$1 [R=301,L]
RewriteRule [.]*-kbc([0-9]*) /portal2.0/kb.php?%{QUERY_STRING}mode=cat&cat=$1 [R=301,L]
RewriteRule [.]*-kba([0-9]*) /portal2.0/kb.php?%{QUERY_STRING}mode=article&k=$1 [R=301,L]
RewriteRule [.]*-kbsmp /portal2.0/kb.php?mode=stats&stats=mostpopular [R=301,L]
RewriteRule [.]*-kbstr /portal2.0/kb.php?mode=stats&stats=toprated [R=301,L]
RewriteRule [.]*-kbsl /portal2.0/kb.php?mode=stats&stats=latest [R=301,L]
RewriteRule [.]*-pbc([0-9]*) /portal2.0/kb.php?%{QUERY_STRING}mode=cat&cat=$1 [R=301,L]
RewriteRule [.]*-pa([0-9]*) /portal2.0/kb.php?%{QUERY_STRING}mode=article&k=$1 [R=301,L]
RewriteRule [.]*-psmp /portal2.0/kb.php?mode=stats&stats=mostpopular [R=301,L]
RewriteRule [.]*-pstr /portal2.0/kb.php?mode=stats&stats=toprated [R=301,L]
RewriteRule [.]*-pbsl /portal2.0/kb.php?mode=stats&stats=latest [R=301,L]

# SANTY
RewriteCond %{HTTP_REFERER} ^.*$
RewriteRule ^.*%27.*$ http://127.0.0.1/ [redirect,last]
RewriteRule ^.*%25.*$ http://127.0.0.1/ [redirect,last]
RewriteRule ^.*rush=.*$ http://127.0.0.1/ [redirect,last]
RewriteRule ^.*echr.*$ http://127.0.0.1/ [redirect,last]
RewriteRule ^.*esystem.*$ http://127.0.0.1/ [redirect,last]
RewriteRule ^.*wget.*$ http://127.0.0.1/ [redirect,last]
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]
RewriteCond %{HTTP_REFERER} ^.*$

# This ruleset is to "stop" stupid attempts to use MS IIS expolits on us
# NIMDA
RewriteCond %{REQUEST_URI} /(admin¦cmd¦httpodbc¦nsiislog¦root¦shell).(dll¦exe) [NC]
RewriteRule !(error.php|robots.txt) /error.php?mode=nimda [L,E=HTTP_USER_AGENT:NIMDA_EXPLOIT,T=application/x-httpd-cgi]
#RewriteRule .* - [F,L]

# CODERED
RewriteCond %{REQUEST_URI} /default.(ida¦idq)$ [NC,OR]
RewriteCond %{REQUEST_URI} /.*.printer$ [NC]
RewriteRule !(error.php|robots.txt) /error.php?mode=codered [L,E=HTTP_USER_AGENT:CODERED_EXPLOIT,T=application/x-httpd-cgi]
#RewriteRule .* - [F,L]


So I created the new line:

Code: [Hide]
  1. RewriteRule ^([a-zA-Z0-9]+).php$ /portal2.0/$1.php [R=301,L] 


to redirect each request for .php file to portal2.0

And the other lines are the original rewrite mod used for XS to redirect them from /portal/ to /portal2.0/

That's is!!


Mighty Gorgon [ Mon 02 Oct, 2006 01:12 ]
Post subject: Re: About .htaccess paths!
Great, that is just what I would have read.

I think this will help someone else.

Thank you.




Powered by Icy Phoenix