Jump to content


.htaccess question.


12 replies to this topic

#1 high6

    Young Padawan

  • Members
  • Pip
  • 57 posts

Posted 25 August 2006 - 08:41 AM

well i was wondering if it was possible to make http://www.dimensiongaming.net/vb4life/Con...hp&level=50 into http://www.dimensiongaming.net/vb4life/Con...pg&level=50 and work on a forum(its not for here).

#2 NGPixel

    Senior Programmer

  • P2L Staff
  • PipPipPipPip
  • 1,410 posts
  • Gender:Male
  • Location:Montreal, Canada
  • Interests:Web Design : Coding : Animation

Posted 25 August 2006 - 03:11 PM

It's possible using ModRewrite

RewriteEngine on
RewriteRule ^sig.jpg?level=([0-9]+)$ sig.php?level=$1


#3 high6

    Young Padawan

  • Members
  • Pip
  • 57 posts

Posted 25 August 2006 - 03:52 PM

View PostNGPixel, on Aug 25 2006, 04:10 PM, said:

It's possible using ModRewrite

RewriteEngine on
RewriteRule ^sig.jpg?level=([0-9]+)$ sig.php?level=$1


how would i use this(after putting in .htaccess)?

RewriteEngine on
RewriteRule sig.jpg sig.php

that works except on forums which is my goal. because it doesnt end with .jpg.

Edited by high6, 25 August 2006 - 03:58 PM.


#4 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 25 August 2006 - 03:54 PM

Once you put it into your .htaccess file, you don't have to do anything apart from using the url 'http://www.dimensiongaming.net/vb4life/ConquerSig/sig.jpg&level=50'. It will automatically rewrite the URL (in the background, you'll never know lol) and sends the broswer to the file with the .php extension. No one would ever be able to tell unless they tried to actually use the .php extention, lol.
It just has to have an image extention to trick the forum into allowing it as an image.

#5 high6

    Young Padawan

  • Members
  • Pip
  • 57 posts

Posted 25 August 2006 - 04:00 PM

View PostDemonslay, on Aug 25 2006, 04:54 PM, said:

Once you put it into your .htaccess file, you don't have to do anything apart from using the url 'http://www.dimensiongaming.net/vb4life/ConquerSig/sig.jpg&level=50'. It will automatically rewrite the URL (in the background, you'll never know lol) and sends the broswer to the file with the .php extension. No one would ever be able to tell unless they tried to actually use the .php extention, lol.
It just has to have an image extention to trick the forum into allowing it as an image.


well using the code he posted i get a 404 error on http://www.dimensiongaming.net/vb4life/Con...pg&level=50 .

also i dont think it would work because it doesnt end in .jpg. i know how to do this but not with variables.

#6 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 25 August 2006 - 04:14 PM

Well for one, the .htaccess has to be in the same directory.
Also some reason I get 404 when using the 'level=50' and the .php extention, yet a blank page without that. :P

It'll work just fine, I use it with this kind of thing n my own site.
http://demonslay.com/dinty_kit/generator-m...mp;fullset=none
That's just a nude figure (not nude nude, just nude, lol) for a generator by the way.
Notice the .png extention nested in there, and all the GET data slapped on. It works fine as long as your rewrites are done correctly.

Edited by Demonslay, 25 August 2006 - 04:17 PM.


#7 high6

    Young Padawan

  • Members
  • Pip
  • 57 posts

Posted 25 August 2006 - 04:50 PM

View PostDemonslay, on Aug 25 2006, 05:14 PM, said:

Well for one, the .htaccess has to be in the same directory.
Also some reason I get 404 when using the 'level=50' and the .php extention, yet a blank page without that. :P

It'll work just fine, I use it with this kind of thing n my own site.
http://demonslay.com/dinty_kit/generator-m...mp;fullset=none
That's just a nude figure (not nude nude, just nude, lol) for a generator by the way.
Notice the .png extention nested in there, and all the GET data slapped on. It works fine as long as your rewrites are done correctly.

but to work on a forum it has to end in .jpg. and cant have all the variables on the end. is there a way to put them before .php?

Edited by high6, 25 August 2006 - 04:50 PM.


#8 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 25 August 2006 - 05:18 PM

No, actually you don't need to, I've been using this technique on multiple forums and it works just fine...

But since you insist (-.-) this is how you'd do it.
RewriteRule ^sig/level-([0-9]+).jpg$ sig.php?level=$1
I just cleaned it up as how I would do it to make it easier to remember, you could even cut it more by taking out the 'level-' completely if you wanted.

#9 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 25 August 2006 - 05:18 PM

Im too tired to read all but as for your last question try:

RewriteEngine on
RewriteRule ^/level([0-9]+)/sig.jpg$ sig.php?level=$1

*yawns after long day* lol.

EDIT: lol. Damn your Demonslay.!

Edited by .Matt, 25 August 2006 - 05:35 PM.


#10 high6

    Young Padawan

  • Members
  • Pip
  • 57 posts

Posted 25 August 2006 - 05:24 PM

thankyou, both those methods works.

quick question. what if i have more then 1 value?

Edited by high6, 25 August 2006 - 05:25 PM.


#11 Matthew.

    Official Spammer .Matt

  • Members
  • PipPipPipPip
  • 2,749 posts
  • Gender:Male
  • Location:England

Posted 25 August 2006 - 05:34 PM

Sorry what do you mean by another value? Another variable?

like: page.ext?var=1&var2=2

?

#12 high6

    Young Padawan

  • Members
  • Pip
  • 57 posts

Posted 25 August 2006 - 05:50 PM

View Post.Matt, on Aug 25 2006, 06:34 PM, said:

Sorry what do you mean by another value? Another variable?

like: page.ext?var=1&var2=2

?

ya but in htaccess.

#13 Demonslay

    P2L Jedi

  • Members
  • PipPipPip
  • 970 posts
  • Gender:Male
  • Location:A strange world where water falls out of the sky... for no reason.
  • Interests:Graphic Design, Coding, Splinter Cell, Cats

Posted 25 August 2006 - 06:53 PM

You should be able to see the pattern going on here.
In regex (regular expressions) (.*) means anything, and ([0-9]+) means any numbers. The regex then stores each one of these in a variable. So the first occurance of something like this, is put into the $1 variable, the second one into the $2 variable, and so on.

So you'd have it basically working like this.
RewriteRule ^(.*)/(.*)/(.*)/(.*)$ /page.php?id=$1&cat=$2&query=$3&page=$4 [nc]






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users