| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| DNOA Member Join Date: May 2004
Posts: 5,040
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | 25 NP$ for a working .htaccess file... Hi, Can I have somebody write a .htaccess file that will redirect all subdirectories with at LEAST 1 dot (there can be more) in it to a .php file? ????: NamePros.com http://www.namepros.com/programming/134000-25-np-for-working-htaccess-file.html Eg: www.domain.com/subdirectory.e Redirects to a file called show.php (in the public_html directory) Then, to the PHP file, send two variables: the text before the FIRST dot (there can be more than one dot in the directory name, like "subdirectory.e.v") and the text AFTER the first dot, but ignoring ALL OTHER dots (the first dot should NOT be included in any variable) So, in this: www.domain.com/subdirectory.e.v Should send only 2 variables to the PHP file: $var1 = "subdirectory" $var2 = "e.v" (There will never be more than 2 dots if you need to know, but always at least 1) 25 NP$ to the person who can do this! Thanks, -Matt |
| |
| | #2 (permalink) |
| NamePros Regular Join Date: Jun 2004 Location: Iowa City
Posts: 705
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | something like this? .htaccess Code: Options +FollowSymLinks RewriteEngine on RewriteBase / RewriteRule (.*).html$ /show.php?value=$1 PHP Code:
__________________ formally ninedogger ------ Want to talk to a stranger? -->| Click Here | TalkToAStranger.com | <-- Meet New Friends |
| |
| | #4 (permalink) |
| NamePros Regular Join Date: Jun 2004 Location: Iowa City
Posts: 705
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | <?php echo $_GET['value']; $data = explode('.', $value); $var1 = $data[0]; // subdirectory $var2 = $data[1]; // e.v ?> im pritty sure you dont need the .html part in that .htaccess, not sure i'll see if that changes the that whole thing
__________________ formally ninedogger ------ Want to talk to a stranger? -->| Click Here | TalkToAStranger.com | <-- Meet New Friends |
| |
| | THREAD STARTER #5 (permalink) |
| DNOA Member Join Date: May 2004
Posts: 5,040
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Thanks... I don't wanna break anything - if you can test it and make sure it works I'll add an extra 10 NP$. UPDATE: I just tested what you gave me and it only works for .html files. It needs to work for ANY subdirectory with at least 1 dot in it. ANOTHER UPDATE: I got it to work with all subdirectories with a dot in it. Now, though, it outputs this all the time: site.ph And that shows up with the second PHP snippet you gave me. 'NOTHER UPDATE: It redirects even when i'm not accessing a subdirectory :'( Grrr. one last thing: It has to ignore .php files... |
| |
| | #7 (permalink) |
| NamePros Regular Join Date: Jun 2004 Location: Iowa City
Posts: 705
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | try: Options +FollowSymLinks RewriteEngine on rewriteRule ^([^_]+)/ /show.php?value=$1 [L]
__________________ formally ninedogger ------ Want to talk to a stranger? -->| Click Here | TalkToAStranger.com | <-- Meet New Friends |
| |
| | THREAD STARTER #8 (permalink) |
| DNOA Member Join Date: May 2004
Posts: 5,040
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Sorry but that doesn't work. It says that, when I type domain.com/sub.directory it says: "sub.directory is not found". Any help appreciated - 100 NP$ reward! EDIT: That snippet you gave me only works if the subdirectories exist... :-/ Otherwise I THINK it's right. |
| |
| | #9 (permalink) |
| NamePros Regular Join Date: Jun 2004 Location: Iowa City
Posts: 705
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | I got it this time...Works when I tested .htaccess RewriteEngine on RewriteRule ^(.*)/$ show.php?value=$1 show.php PHP file (for testing) <?php echo $value; ?> I got it to only work when / was at the end of the url example: w ww.domain.com/document.title/
__________________ formally ninedogger ------ Want to talk to a stranger? -->| Click Here | TalkToAStranger.com | <-- Meet New Friends |
| |
| | THREAD STARTER #10 (permalink) |
| DNOA Member Join Date: May 2004
Posts: 5,040
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Get it to work without that slash and i'll give you 110 NP$. UPDATE: It also will kick in if the string DOESN'T have a dot... if you can fix that then that'd be great but you don't absolutely HAVE to. It won't kill my project But that ending slash will. |
| |
| | #11 (permalink) |
| NamePros Regular Join Date: Jun 2004 Location: Iowa City
Posts: 705
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | Code: RewriteEngine on
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} !\.
RewriteRule (.*) http://www.domain.com/directory/$1/ [R=301,L]
RewriteRule ^(.*)/$ show.php?value=$1 100% Confident this time! It will automatically add the / at the end if its not there (it is required) so now it works with or w/o
__________________ formally ninedogger ------ Want to talk to a stranger? -->| Click Here | TalkToAStranger.com | <-- Meet New Friends |
| |
| | #13 (permalink) | ||||
| NamePros Regular Join Date: Jun 2004 Location: Iowa City
Posts: 705
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
__________________ formally ninedogger ------ Want to talk to a stranger? -->| Click Here | TalkToAStranger.com | <-- Meet New Friends | ||||
| |
| | #15 (permalink) |
| NamePros Regular Join Date: Jun 2004 Location: Iowa City
Posts: 705
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | So many FAILED attempts Would you settle for this? Code: RewriteEngine on
RewriteCond %{REQUEST_URI} !/$
RewriteCond %{REQUEST_URI} (\.com|\.net|\.org)
RewriteRule (.*) http://www.gamingempires.com/test/$1/ [L]
RewriteRule ^(.*)/$ productinfo.php?prodID=$1 ????: NamePros.com http://www.namepros.com/showthread.php?t=134000 The only thing that that allows is .com/.net/org (lowercase) you can add more extensions This is the only solution I could come up with at first it was: !\. but that caused problems when there was just domain.com tested this over and over and seems to be good
__________________ formally ninedogger ------ Want to talk to a stranger? -->| Click Here | TalkToAStranger.com | <-- Meet New Friends |
| |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| MusicSharing.net | Domainut | Domains For Sale - Make Offer | 13 | 01-30-2004 09:15 PM |