Web Hosting Talk


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : ModRewrite Rules: Tricky Question
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.

 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-21-2008, 12:15 PM
RSMN RSMN is offline
View Beta Profile
Junior Guru Wannabe
 
Join Date: Sep 2006
Posts: 79
* ModRewrite Rules: Tricky Question

I'm writing a url shortening app for my company, and I'm using mod_rewrite to parse the 5 digit code (ie. www.example.com/ASDFG) and pass the code to a script.

I already have all the scripts written, my problem is that I also have pages such as www.example.com/admin.aspx and mod_rewrite is sending a code of "ADMIN" to the URL shortening script and not serving the actual page.

Does anyone have a rewrite rule that states if what comes after the first slash is 5 characters AND ONLY 5 characters, then to push it to that script?

Thanks for your help!

Reply With Quote
Sponsored Links
  #2  
Old 08-21-2008, 12:39 PM
ThatScriptGuy ThatScriptGuy is offline
View Beta Profile
Web Hosting Master
 
Join Date: Feb 2003
Location: AR
Posts: 2,119
What you should be doing in your .htaccess (Pseudo-code style) is this:

Code:
RewriteEngine On
if requested URL is not a file
if requested URL is not a directory
Pass code to script
RewriteCond %{REQUEST_FILENAME} !-f # Existing File
RewriteCond %{REQUEST_FILENAME} !-d # Existing Directory

Kevin

__________________
Kevin Cackler
That Script Guy
(479) 437-9874

Reply With Quote
  #3  
Old 08-21-2008, 12:55 PM
RSMN RSMN is offline
View Beta Profile
Junior Guru Wannabe
 
Join Date: Sep 2006
Posts: 79
Wow. I knew that, but I just didn't put 2+2 together.

I really feel like an idiot now!


Thanks!

Reply With Quote
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement: