TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 12-20-2009, 02:56 PM   #1 (permalink)
The Frequenter
 
ReSpawN's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 460
Thanks: 49
ReSpawN is on a distinguished road
Default .htaccess, rewriting url

I've been trying to rewrite my url to do the following.

I've got a file (image) stored in /gallery/media/avatar/n/r/ and the filename respawn.jpg. Through .htaccess, I would like to aproach the URL through this url: http://avatar.domain.tld/n/r/respawn.jpg

The question is, how? My script keeps rewriting the URL. I can aproach it, but the URL changes upon find.

PHP Code:
RewriteCond %{HTTP_HOST}     ^avatar\.domain\.tld$ [NC]
RewriteCond %{REQUEST_URI}     ^/avatar/(.*)/(.*)/(.*) [NC]
RewriteRule (.*) http://www.google.nl/$1/$2 [NC] 
Do not mind the google.nl part, that was just for testing. I feel like I am on the righ track, but I can't seem to get it to work.

I followed some instructions on http://corz.org/serv/tricks/htaccess2.php, perhaps someone can use it.

Looking forward to some responses.

ReSpawN
__________________
"Life is a bitch, take that bitch on a ride"
Send a message via MSN to ReSpawN
ReSpawN is offline  
Reply With Quote
Old 12-23-2009, 01:06 AM   #2 (permalink)
is cute and cuddly
 
delayedinsanity's Avatar
 
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
delayedinsanity is on a distinguished road
Default

The first problem is probably that you're capturing three groups, and only returning two.

php Code:
RewriteCond %{HTTP_HOST} ^avatar.domain.tld$ [NC]
RewriteRule ^/([_0-9a-zA-Z-]+/)?([_0-9a-zA-Z-]+/)?([^.]+\.[A-Za-z]{3,4})$ http://www.domain.tld/avatar/$1$2$3
 

I don't know your specific needs, so I just wrote it based off your existing rules. This should grab any address from http://avatar.domain.tld/something/s.../something.ext and find the actual file at http://www.domain.tld/avatar/somethi.../something.ext (untested). Modify to suit your needs. :)
delayedinsanity is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
.htaccess gives some trouble afraca General 1 11-21-2009 08:29 PM
Problems with .htaccess URL Rewrite TheOnly92 General 0 04-22-2009 11:07 AM
.htaccess problem with godaddy? sarmenhb General 3 10-09-2008 04:36 PM


All times are GMT. The time now is 07:48 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design