|
|
|
|
Thread title: Help with case sensitivity issues |
|
|
|
|
|
Thread tools
Search this thread
Display Modes
|
|
02-11-2011, 09:55 PM
|
#1
|
Status: I'm new around here
Join date: Feb 2011
Location: Joplin, MO, USA
Expertise: Design & Building basic sites
Software: DreamWeaver, Photoshop, FileZi
Posts: 9
|
Help with case sensitivity issues
I am building a small site for a client, and he is wanting a text box on the home page where someone can put in a code and be taken to another page in the site.
The easiest way I found to do this was with the following code.
The part is in the header
<script>
function changeURL(){
window.location =
document.getElementById('txtbx').value + ".php";
}
</script>
This part is in the body.
ACCESS CODE: <input type="text" value="" id="txtbx" />
<input type="button" value="Submit" onmousedown="changeURL();" />
This code does what we want, for the most part. The issue is that he has mailed out the flyers with the code 7STAR. I therefor named the page 7STAR.php and when the code is entered in all caps, it works great. The problem is that we can't count on everyone actually putting it in all caps. The client also has expressed that he does not want me to put a message on the page about all caps. (he has the site exactly how he wants it in his head and is not open to any variation from that. (I'm sure most of the rest of you have had an occasional client like that)).
What I need to know is if there is a way to use HTACCESS to automatically redirect if someone puts in 7Star or 7star. I would also be open to some javascript that may change it on the homepage when someone keys it in.
I appreciate any help anyone can offer on this.
|
|
02-11-2011, 10:01 PM
|
#2
|
Status: I'm new around here
Join date: Feb 2011
Location: Joplin, MO, USA
Expertise: Design & Building basic sites
Software: DreamWeaver, Photoshop, FileZi
Posts: 9
|
I just had the thought to create the two extra pages, 7Star.php and 7star.php and have redirect scripts in them to take them to the correct page, but I would rather not do this if I don't have to.
Thanks in advance for any help
|
|
02-11-2011, 10:54 PM
|
#3
|
Status: Member
Join date: Jan 2011
Location:
Expertise: Programming, photography
Software: Notepad++, Photoshop
Posts: 112
|
This should do it if the 7star.php file is in the root directory of your website. It should work, I tested it.
PHP Code:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^7star.php /7STAR.php [r=301]
This will redirect it from 7star.php to 7STAR.php. Sometimes you'll need to leave the "Options +FollowSymlinks" out. This depends on the server.
I hope that helps.
EDIT: Of course this goes into a .htaccess file placed in the root directory of your public folder.
|
|
02-11-2011, 11:12 PM
|
#4
|
Status: I'm new around here
Join date: Feb 2011
Location: Joplin, MO, USA
Expertise: Design & Building basic sites
Software: DreamWeaver, Photoshop, FileZi
Posts: 9
|
This looks great!!
Will this work with two rewrite rules? One for 7Star and one for 7star?
Thanks again.
|
|
02-11-2011, 11:41 PM
|
#5
|
Status: Member
Join date: Jan 2011
Location:
Expertise: Programming, photography
Software: Notepad++, Photoshop
Posts: 112
|
Sure, add a new line just below:
PHP Code:
RewriteRule ^7Star.php /7STAR.php [r=301]
If you already have an .htaccess file, then just copy it below and make sure the first two lines only exist once.
|
|
02-12-2011, 12:30 AM
|
#6
|
Status: Geek
Join date: Apr 2006
Location: Denver, CO
Expertise: Software
Software: Chrome, Notepad++
Posts: 6,894
|
Also, if you want a solution in javascript :
Code:
var b = 7Star'
document.write(b.toUpperCase() + '.php') //will write 7STAR.php
|
|
02-12-2011, 12:31 AM
|
#7
|
Status: I'm new around here
Join date: Feb 2011
Location: Joplin, MO, USA
Expertise: Design & Building basic sites
Software: DreamWeaver, Photoshop, FileZi
Posts: 9
|
I tried adding your code to my current .htaccess file and still if I type 7Star or 7star I end up at my error page. I have pasted my .htaccess file below so you can see what I ended up with after adding your code. Below that will be my original .htaccess code so you can compare and hopefully point me in the right direction.
<--begin new .htaccess file-->
AddType x-mapp-php5 .php
Options +FollowSymlinks
RewriteEngine On
RewriteRule ^7Star.php /7STAR.php [r=301]
RewriteRule ^7star.php /7STAR.php [r=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.php) /error.php
<--end new .htaccess file-->
<--begin original .htaccess file-->
AddType x-mapp-php5 .php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.php) /error.php
<--end original .htaccess file-->
|
|
02-12-2011, 12:54 AM
|
#8
|
Status: Member
Join date: Jan 2011
Location:
Expertise: Programming, photography
Software: Notepad++, Photoshop
Posts: 112
|
|
|
02-12-2011, 01:38 AM
|
#9
|
Status: I'm new around here
Join date: Feb 2011
Location: Joplin, MO, USA
Expertise: Design & Building basic sites
Software: DreamWeaver, Photoshop, FileZi
Posts: 9
|
Eightloop, yes, that is correct on what I am trying to do. It did work this time with the "Options +FollowSymlinks" removed. Also, I tried the JS solution from Village Genius and it worked as well. I will hang on to both of these options since I am building this site on my hosting server and my client hasn't decided who he is going to use for his hosting yet so who knows what will happen if I end up dealing with another host's configurations.
Thank you both so much for your help!!
|
|
|
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
|