Jump to content

click

Members
  • Content Count

    138
  • Joined

  • Last visited

Everything posted by click

  1. Yeah, busy around here all of a sudden. SteveW's rewrite rule will redirect the browser and the visitor will see the new address in their browser. The [R=301] tells it to redirect. Use this if a page has been moved. Without the [R] flag, the server will serve file.html but /directory/ will still show in the visitor's browser -- there is no indication to the visitor that the request has been redirected. Choose whichever behavior you're after
  2. Add the following to .htaccess file >RewriteEngine On RewriteRule ^directory/?$ file.html [NC]
  3. If you're asking if that's the correct way to define and call a function, then yes. You don't HAVE to separate it into functions, but it makes it easier to read and maintain if it's broken down into logical chunks. I'm a little unclear on something: Is the query only returning one story or many? You say that you want to use $story['headline'] as the page <title>, but you set and display $story in a while loop, implying that the database is going to return more than one story. If you're only displaying one "story", then just connect to the database and put the results in the variable $story before the "include('header.php');". That way, $story['headline'] will have been initialized for header.php to use.
  4. You need to split your code up into functions defined at the top of the file. As soon as the page loads, pull the info from the database. Then call a separate function from the body of your page that will actually display the info (all your "echo" statements). Also, make sure you're sanitizing the input before you use it in a db query or your script may be vulnerable to SQL injection attacks.
  5. I'm also wondering about those dates. Possibly someone was looking at October's calendar instead of November, as 10/13, 10/21 & 10/28 all fall on weekends (and aren't the day before Thanksgiving)?
  6. Those backslashes in your RewriteRules don't look right to me. If you're trying to escape the periods, then the backslash should go before them rather than after. Also, you don't need to escape the periods in the second part because you're not matching anything. Try this: >RewriteEngine On RewriteRule ^css/(.*\.css) /combine.php?type=css&files=$1 RewriteRule ^javascript/(.*\.js) /combine.php?type=javascript&files=$1
  7. I guess I misunderstood. I thought you were wanting to ignore the query string and redirect all requests to the new URL. Anyhow, I'm glad you figured it out.
  8. I believe something like this should do what you want. >RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?olddomain\.com$ [NC] RewriteRule ^olddir/directory\.php$ http://www.newdomain.com/directory.php [R=301,L]
  9. I don't know if this is the best way to do it or not, but this should work: list( $fieldname, $value ) = preg_split( '/(\\{\\$.+\\$\\})/', $string, 2, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE );
  10. Oh, duh! Good job figuring it out. I knew we had to be missing something simple. Without the [L], it was still running it by the other rewrites which were regenerating the query string.
  11. Does it work if you just type the address you're redirecting to into the address bar? What URL is it trying to open when it generates the 404? I notice that your redirect refered to "Wall-Sconses_2_4.php " but later you said it redirects to "Wall-Sconces_2_4_1.php". Is that a typo in the redirect maybe? "RewriteRule ^products/Wall-Sconses(.*)\.php /products/Wall-Sconces$1.php? [R=301,NC]" should take care of anything beginning with "Wall-Sconses".
  12. The rewriterule should replace the redirect. Try putting the new RewriteRule before the others (directly beneath the "RewriteEngine On")
  13. Are you just wanting to strip off the query string? If so, I think this should work. Add it somewhere below "RewriteEngine On" >RewriteRule ^products/Wall-Sconses_2_4.php /products/Wall-Sconces_2_4.php? [R=301,NC]
  14. Assuming you're on a shared server, make sure you're adding cPanelUsername_ to both the database and user names in wp-config.php.
  15. If it had been cropped, the shortened name would be shown in cPanel so it doesn't sound like that's the problem. Looking at one of my usernames, it looks like it shortens them to 16 characters.
  16. Also, I believe MySQL usernames will be cropped if they're too long, so make sure the info in wp-config.php matches what is shown on the MySQL page in cPanel. Double check the password, too. edit: ... and that the user has "ALL PRIVILEGES" for the database.
  17. Yeah, my old server would occasionally be a little sluggish... Not anymore. MUCH faster! And consistently so.
  18. hahaha I think that officially makes me a moron! Sorry, I don't know how I managed to miss that. I guess the $ variables threw me into php mode (I haven't done any significant perl in a while). Maybe there should be some basic IQ test before we're allowed to post. I think the Perl split() works pretty much the same as preg_split(), though. Any part of the regex in parenthesis will be included in the result array. Anyhow, I'm glad you figured it out.
  19. OK, looks like this should give you what you want.... I think >$string = 'xxxxxxxxyyyy'; $regex = '/(xxxxxxxx)/'; $result = preg_split( $regex, $string, 2, PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE );
  20. I believe preg_split() may be what you want. Check out: http://www.php.net/manual/en/function.preg-split.php On second thought, it doesn't look like there's anything separating the two parts of your string so it may not be exactly what you're looking for.
  21. Holy Cow! Where's my decoder ring?!
  22. That didn't seem very appropriate/professional.
  23. Could have been, I'm not really sure. I just knew it worked with it at the beginning.
  24. BTW, that expression is not an entirely correct way to validate addresses. It will, for instance, fail addresses with more than 3 letters in the domain, such as .info. You can find a pretty good example of a php email validator at http://www.ilovejackdaniels.com/php/email-...ess-validation/
  25. In '[_a-z0-9-]', the last '-' is being seen as defining a range rather than a literal dash. Move it to the beginning to prevent this. So it would be: [-_a-z0-9]
×
×
  • Create New...