Portal Home > Knowledgebase > Articles Database > htaccess help
htaccess help
Posted by smrtalex, 12-29-2009, 10:02 PM |
Need some .htaccess assistance.
This is the way the URL it is seen in the address bar:
http://www.domain.com/test/test_file.php?file_name={file_number}
This is what I would like to have happen:
If the "{file_number}" variable equals "{file_number}" then I want to redirect it to http://www.domain.com/test/index.php
If the "{file_number}" variable equals anything but "{file_number}" then it is ok.
And I would like to put the .htaccess file in the 'test' directory.
Any help would be greatly appreciated!
|
Posted by propcgamer, 12-30-2009, 04:05 AM |
So if I understand, file_number will always be a number, and if it isnt a number, dont redirect it?
|
Posted by smrtalex, 12-30-2009, 05:37 AM |
That is correct! Basically if it is anything but a number, it needs to be redirected!
Thanks!
|
Posted by TotalZen, 12-30-2009, 06:27 AM |
Try this...
Last edited by TotalZen; 12-30-2009 at 06:30 AM.
|
Posted by TotalZen, 12-30-2009, 07:06 AM |
TBH, this is much better suited to being done within the PHP script itself, using the is_numeric function for sanitizing input.
|
Posted by smrtalex, 12-30-2009, 08:30 AM |
While I agree with you, just looking for a quick bandaid at the moment!
Thanks!!! This is doing good, but unfortunately it is also redirect all URL's like:
http://www.domain.com/test/test_file.php?file_name=1
http://www.domain.com/test/test_file.php?file_name=25
http://www.domain.com/test/test_file.php?file_name=345
http://www.domain.com/test/test_file.php?file_name=1225
Not sure if it matters but the file_name variable could be a numeric variable up to 5 digits.
Any thoughts!
Thanks again!
|
Posted by blue44, 12-30-2009, 08:48 AM |
Hi, here is a good tutorial i finished this morning: http://www.nodstrum.com/2009/12/30/m...-php-tutorial/ hopefully it will help you out a little.
|
Posted by smrtalex, 12-30-2009, 08:53 AM |
Didn't really help my situation, but thanks anyway!
|
Posted by blue44, 12-30-2009, 08:58 AM |
no worries - good luck with it
|
Posted by smrtalex, 12-30-2009, 09:01 AM |
This seems to be working:
TotalZen.... Many Thanks!!!
|
Posted by TotalZen, 12-30-2009, 09:31 AM |
Yeah I moreless just posted that rewrite rule as a pointer to the exact solution because fine-tuning it would involve more info being neeed concerning the boundries of the query.
But I see you've got a workable solution now.
|
Posted by TotalZen, 12-30-2009, 10:18 AM |
I re-read your posts above and I think this is what you really want here...
|
Add to Favourites Print this Article
Also Read
vmware esxi (Views: 691)