User Name
Password
AppleNova Forums » Programmer's Nook »

Modrewrite and Hyphens


Register Members List Calendar Search FAQ Posting Guidelines
Modrewrite and Hyphens
Thread Tools
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2015-08-11, 00:15

I'm working on a website right now and have some top-level page names like these:

Home
Advisory Services
Project Services
Contact
About

They're pulled from a database that I've created and used as navigation links, with hyphens between the words.

I'm using an htaccess file to do a mod-rewrite so that page URLs are shown like this:

example.com/home
example.com/advisory-services
example.com/management-services
example.com/contact
example.com/about


Standard stuff.

The rewrite rule uses this:

Code:
RewriteRule ^/?([a-zA-Z_0-9\-]+)/?$ index.php?bar=$1 [L]
(the contents are escaped inside of '/?' because of the environment)


The index.php page checks to see if a value has been passed:

Code:
if (isset($_GET['bar'])) { $foo=$_GET['bar']; }

Each of the previously mentioned links passes this check EXCEPT for the one named "advisory-services".

That one is not passed along and gets the warning "No passed variable".



If I go into the database and change a letter in that link to something like "advisory-servicef", it works fine.

Lots of variations have worked, but whenever I change it back to "advisory-services" it fails.


I am supremely confused.

And sleepy.

g'nite




...

Steve Jobs ate my cat's watermelon.
Captain Drew on Twitter
  quote
Dave
Ninja Editor
 
Join Date: May 2004
Location: Bay Area, CA
 
2015-08-11, 08:59

Do the back-end names have to be in English? "consultorium servicia"
  quote
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2015-08-11, 09:23

LOL

I'd rather that they be the same so I don't have to create a translation routine

Just to humor you, I replaced "advisory services" with "consultorium servicia" and it worked perfectly!

And, just for shits and giggles, I changed an entry farther down in the database to "advisory services" and it balked in the same way documented previously.

A new day of trying to suss out what exactly is happening...



...

Steve Jobs ate my cat's watermelon.
Captain Drew on Twitter
  quote
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2015-08-11, 09:26

Oh! Of note: the entries in the database do NOT have hyphens in them - only spaces.

That's something that I'm doing in my code when generating the links.


example.com/home
example.com/advisory-services
example.com/management-services
example.com/contact
example.com/about



...

Steve Jobs ate my cat's watermelon.
Captain Drew on Twitter
  quote
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2015-08-11, 23:02

Just to close the loop, I figured it out.

I just don't know what I did to figure it out.

I hate that, but it is what it is.




...

Steve Jobs ate my cat's watermelon.
Captain Drew on Twitter
  quote
ThunderPoit
Making sawdust
 
Join Date: May 2004
Location: Minnesota
 
2015-08-12, 11:27

I just wanted to add, is something like this in your actual code?

Code:
$foo=$_GET['bar'];
I hope you're taking steps to validate and escape that data, especially if it goes anywhere near your database.
  quote
drewprops
Space Pirate
 
Join Date: May 2004
Location: Atlanta
 
2015-08-13, 00:39

Is this what you're talking about?

Never Use $_GET Again



...
  quote
ThunderPoit
Making sawdust
 
Join Date: May 2004
Location: Minnesota
 
2015-08-13, 13:49

Basically, yes. I've been working with Silex and Symfony a lot lately, and its made me rethink everything I thought I knew about php and security. Long story short, never trust data from the client
  quote
709
¡Damned!
 
Join Date: May 2004
Location: Purgatory
 
2015-08-26, 08:34

[quote=addseo1234;792084]especially if it goes anywhere near your database.
[url=https://www.SPAMMITYSPAM.com/livescore/][color=#D3DAE3]ผลบอล[/color][/url][/quote]


^ First time I've seen them using the background color to hide a spam link. Sneaky!
  quote
Posting Rules Navigation
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

Post Reply

Forum Jump
Thread Tools

« Previous Thread | Next Thread »

All times are GMT -5. The time now is 14:22.


Powered by vBulletin®
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004 - 2024, AppleNova