ทุกข์
ในการติดตั้ง WordPress แบบโฮสต์เอง มักจะเกิดปัญหาขึ้นอย่างหนึ่งคือเวลากดดู post ทีมี title เป็นภาษาไทย จะพบกับหน้า error, not found แต่ปัญหานี้ไม่พบใน post ทีมี title เป็นภาษาอังกฤษ
หมุทัย
ถ้าผู้ใช้เขียน post title เป็นภาษาไทย WordPress มันจะสร้าง Permalink ให้อัตโนมัติโดยมีภาษาไทยอยู่ใน URL (ส่วนขวาสุดของ URL นี้เรียกว่า slug) นี่อาจจะเป็นสาเหตุให้เกิดความผิดพลาด เพราะมีบางอย่างในระบบไม่ชอบ URL ภาษาไทย ซึ่งอาจจะเป็นที่ browser, encoding ของ server, MySQL database ฯลฯ
นิโรธ
เป้าหมายการแก้ปัญหามีหลายระดับ เช่น
- แก้ขัด โดยแก้ไขให้ Permalink (URL) ที่สร้างอัตโนมัติโดย WordPress นั้นไม่เป็นภาษาไทย
- แต่ถ้าจะให้ดี ต้องแก้ให้สามารถใช้ URL ภาษาไทยได้
สำหรับบทความนี้ จะมุ่งเป้าง่ายๆ ที่ #1
ส่วน #2 นั้นคงจะมีทางทำได้ แต่ผู้เขียนยังไม่ทราบ ถ้าท่านทราบโปรดชี้แนะด้วย
มรรค
วิธีการแก้ไขมีอยู่หลายหนทาง หนทางหนึ่งที่ใช้แล้วได้ผลคือ
- มองหาไฟล์ formatting.php ซึ่งอยู่ใน wp-includes
- ทำการสำรองไฟล์ formatting.php (เช่น copy ให้เป็น formatting_original.php)
- แก้ไขไฟล์ formatting.php ดังนี้:
- เติมฟังก์ชั่นสามฟังก์ชั่นนี้ ตรงไหนก็ได้ (ท้ายไฟล์เลยก็ได้)
function mockTitleLooksOK($title) { $t = str_replace(' ', '', $title); $t = str_replace('-', '', $t); return !preg_match('/[^A-Za-z0-9]/', $t); } function mockRandChar() { $t = "abcdefghijklmnopqrstuvwxyz"; #letters only $idx = rand(0, strlen($t)-1); return substr($t, $idx, 1); } function mockSanitizeTitle($title) { if (mockTitleLooksOK($title)) return $title; $title = mockRandChar().mockRandChar().rand(1000, 9999).mockRandChar().mockRandChar().rand(1000, 9999).mockRandChar().mockRandChar(); return $title; }
- มองหา function sanitize_title แล้วมองเข้าไปในฟังก์ชั่นนั้น
- มองหาบรรทัดที่เขียนว่า return $title;
- เติม code บรรทัดต่อไปนี้เข้าไปก่อนหน้าบรรทัดที่มีคำว่า return
$title=mockSanitizeTitle($title); # by mock
- เติมฟังก์ชั่นสามฟังก์ชั่นนี้ ตรงไหนก็ได้ (ท้ายไฟล์เลยก็ได้)
- save ไฟล์ formatting.php
- refresh หน้า WordPress admin แล้วลองเขียน post ใหม่ที่มี title เป็นภาษาไทยได้เลย จะพบว่า slug (ท่อนขวาสุดบน Permalink) ที่ระบบสร้างให้กับคุณจะเป็นตัวอักษร+ตัวเลขแบบมั่วๆ เช่น ai3167sh1984pb
แต่ถ้าคุณเขียน title เป็นภาษาอังกฤษล้วนๆ slug ก็จะเป็นภาษาอังกฤษคล้ายกับ title ของคุณแบบสวยๆ ตามเดิม
- คุณยังมีสิทธิเปลี่ยนแปลง slug เอง (เป็นภาษาอังกฤษและตัวเลข) อยู่ดี
เจริญพร
ตัวอย่างไฟล์
- ไฟล์ formatting-php สำหรับ Version 4.6.1 (ระวังอย่างเผลอ copy ไปทับ version ที่ใหม่กว่า)
ทดสอบ spam detection ของระบบ
Another problem with WordPress is Page Not Found error.
Here’s how to fix. Take these 3 steps.
STEP 1:
– Check /etc/apache2/apache2.conf and all the included file.
– Make sure that AllowOverride None are changed to AllowOverride All
– This is to make Apache honors the .htaccess file that WordPress creates.
STEP 2:
– run this command (on Terminal):
sudo a2enmod rewrite enable
STEP 3:
– restart apache
sudo service apache2 restart
sources:
[1] http://stackoverflow.com/questions/19018702/wordpress-permalink-not-found-on-this-
server
[2] http://stackoverflow.com/questions/29074376/404-not-found-the-requested-url-url-name-not-found-on-this-server-in-wordp
Hello colleagues, how is the whole thing, and what you would like to say concerning this paragraph, in my view its genuinely remarkable for me.
I relish, result in I discovered just what I used to be
looking for. You’ve ended my 4 day long hunt! God Bless you man. Have a
nice day. Bye
Hi there, I desire to subscribe for this website to get most up-to-date updates, thus where can i do it please assist.
Good answer bаck in return օf thіs matter ith genuine arguments аnd describing ɑll
оn the topic of tһat.
hi I’m dr. McQueen I’m going to exhibit you good luck anti-aging products only at the drugstore so follow me search for products that have
peptides a good example of an item which has peptides could be the Olay Regenerist here we are targeting fine lines
and wrinkles once we apply this device overnight one of the very most obvious manifestations of skin aging are fine lines and wrinkles the ingredient to consider for
treating this dilemma is retinol a brand called ROC is extremely famous for its retinol containing products when applied
overnight with time you will see a slow correction in the looks of fine lines and wrinkles skin aging does begin to manifest when you’re in your 20s so it’s important to start young so you
stay young an example of a brand that’s really targeting a younger crowd is
Garnier and Garnier does so by depending a great deal on plant derived
ingredients but the product is particularly good as
it not merely has salicylic acid which will gently exfoliate your skin but it addittionally has soy which will be known for its anti-aging benefits regardless of what age you are I creams are really important the important thing ingredients to find listed here are items that will de-puff the eyes
and those include things like caffeine I’m a novel in theobromine a really good exemplory case of a deep puffing
eye cream could be the Loreal eye defense and you will see results really quickly with the merchandise such as this because
it will contain the caffeine which constricts the puffiness around the eyes.
I’m impressed, I must say. Rarely do I encounter a blog that’s equally educative and amusing,
and let me tell you, you’ve hit the nail on the head. The problem iss aan issue that too feww
men and women are speaking intelligently about.
I am very happy I cane across this during my search for something relating to this.
Ηi, Neat post. Tһere is a prօblem aⅼong with youг site іn internet explorer,
could check this? IЕ stikl іs the market leader and a large elemnt
oof folks wiⅼl mmiss yߋur fantastic writing Ƅecause of tһiѕ рroblem.
I’m so excited for you yourself to lose weight happily and keep it off for good.
Because you can drop these pounds. You may get the body you want.
And you’re not going to accomplish it alone. You can find tens and thousands of people as you, unhappy in their health and desire to change.
I see them professionally, as a registered dietitian nutritionist
with my own, personal private practice. A lot more than 240,000 others have signed up
for 2B Mindset, my online course and system for simple and
sustainable weight loss. These folks have shed 20, 30, 50, even 100+ pounds and rediscovered their best selves because of the unique, easy and effective guiding principles found within the
program videos and resources—and in this book.
I understand you are able to drop the weight because I dropped the weight—plenty of weight—by using this very
same plan. People say they can’t believe it when they see me,
but I spent my youth morbidly obese, weighing a lot more than 200 pounds at
my heaviest. I’ve experienced this struggle. I understand
exactly how it feels. I get that there are temptations
and cravings. I realize that big wins are generally accompanied by bigger setbacks.
I understand what it’s want to feel like the body you’re in doesn’t
reflect you inside. I also realize that I lost 100 pounds—and that I’ve kept it off.
I know that I still love food and eating a lot of it.
I understand that I’m happier and healthier than ever
before. And I am aware you can be, too. The techniques in You
Can Drop It! work. They work because they’re the result
of proven methods combined with science-backed nutrition advice.
My clients pay a lot more than $400 one hour for this counsel.
After seeing how amazing they look and feel during our sessions together—and even months and years
later—I knew I couldn’t hold these solutions back from those that actually need it.
My lifelong goal is to simply help real people as you and me slim down in the absolute most empowering and enjoyable way possible.
It thrills me to share my secrets with you here and a lot more at 2BMindset.com
because I’m committed to having this benefit you.
Inside you’ll get practical strategies to assist you discover ways to
eat with purpose, live your lifetime and lose weight to help you keep it off
for good. And although I’ll motivate you on the way, I’m not just some rah-rah cheerleader (though if you say I seem like one, I won’t complain!).
I am a Registered Dietitian Nutritionist (the highest standard in nutrition).
I’ve a Master of Science in nutrition. I sit on the prestigious Executive Leadership Team for the American Heart
Association and lecture for the Bruin Health Improvement Program at
UCLA.
I’m in the National Weight Control Registry—this is the longest study
out there on fat loss in America of people who lost weight and kept it off.
And I created the 2B Mindset with Beachbody, the pros
behind P90x, INSANITY, and other fitness programs which
have helped thousands of people have the bodies they deserve from the comfort of their homes.
I also have a degree in tough love or PYF—pushing you further.
I might seem too direct sometimes, but I think work equals bigger results, and I am involved with results,
namely yours. You just get one body, I usually say. So you may
as well make it rock! To become listed on in, you don’t have
to purchase into some new fad or spend thousands on exercise equipment or quit
carbs forever. You only need the best guidance and a new…mindset.
This is probably not the very first time you’ve attempted
to lose weight. I’m sure in the past, you’ve gained some weight and—maybe after being inspired or embarrassed or frustrated—decided it absolutely was time to reduce it.
What did you do? Maybe promise yourself you’d fast or cleanse or try really, really hard to eat
perfectly for each day, weekly, or perhaps a month. And
maybe you even succeeded. And I give you credit for your willpower because I never stood the opportunity using
those methods. Or perhaps all of the strictness, discipline and effort frustrated you because you merely saw only a little success and felt such as a failure.
So you got sluggish and sad. Your power crashed, and you went looking
for something to make you feel better. Why, hello, leftover cookies and jar of peanut butter!
That’s whenever you gave in—and felt guilty that you did.
Which means you thought we would wave the white flag and surrender… again. And your weight
returned up… again. That mindset doesn’t work—and it hasn’t
worked for huge numbers of people experiencing their weight who have been trying those same methods.
The mindset that does work—as shown by hundreds and hundreds of my clients
and the a huge selection of thousands more who have used this program—is
the 2B Mindset. Why? Because the 2B Mindset was created to
be sustainable from day one. It doesn’t shame you for your love of food, busy schedule,
skipped workouts, or lack of meal prep; it works together you
and your real life!
It redefines your relationship with food and the manner in which you think
of eating. You won’t ever be told to cut out sweets, but the cool thing is, once you have a fresh mindset, you
may never want them the exact same way. And it starts with
having an excellent relationship with the human body, which, consequently,
also contributes to super-effective weight loss. Ultimately, the 2B Mindset
is rooted in this fundamental truth about nutrition: Weight loss is approximately what food you eat,
but additionally it is about your eating behaviours, reaction to hunger and food environments, and tips on how
to determine what works best for you personally and your body.
We all have different bodies, all of us like different foods and all of us have different lifestyles and schedules.
I have read so many articles or reviews regarding the blogger lovers except this piece of writing is really a pleasant paragraph, keep it up.
Eating meal replacement shakes for the full meal takes
some getting used to, particularly if you haven’t been keen on the taste of plant-based products.
The shakes do vary in flavour. You can find some that have vanilla and chocolate flavour.
You have access to a different taste from using different varieties of milk, whether
it’s almond, soya or coconut milk. Or you might widen your options and include other ingredients from your own fridge and fruit basket.
There are certainly a large amount of ways in which you
can enhance your shake. The Nutribuddy website has an interesting
guide on vegan meal replacement shakes that you could check out.
You can put some blueberries which are good for the heart and helps lowering cholesterol within the body,
raspberries which have some anti-ageing effects, and strawberries that are rich in antioxidants.
You might mix them up as you shake your powder meal or you can just slice
them and have a burst of flavour in your mouth.
You might be creative in what you add to your shake. Whatever fruit is in season, you are able to slice that up as a food topping.
As opposed to putting it into your salad,
you may add kale, carrots, spinach and other vegetables and greens.
It all depends on your own taste and preference.
If you have a case of nuts, add them to your meal for
a richer source of magnesium, vitamin E and other
minerals.
Great post 조개모아! I am actually getting 무료성인야동ready to across this information 무료야동사이트, is very helpful my friend 한국야동. Also great blog here 실시간야동 with all of the valuable information you have 일본야동. Keep up the good work 성인사진 you are doing here 중국야동. 무료야동
Great post 먹튀중개소! I am actually getting 토토사이트ready to across this information 먹튀검증, is very helpful my friend 온라인카지노. Also great blog here 먹튀검증사이트 with all of the valuable information you have 안전놀이터. Keep up the good work 먹튀사이트 you are doing here 먹튀사이트. 검증사이트
Great post 여기여! I am actually getting 주소모음ready to across this information 링크찾기, is very helpful my friend 사이트주소. Also great blog here 링크모음 with all of the valuable information you have 모든링크. Keep up the good work 주소찾기 you are doing here 사이트순위. 링크사이트
Great post 조개모아! I am actually getting 무료성인야동ready to across this information 무료야동사이트, is very helpful my friend 한국야동. Also great blog here 실시간야동 with all of the valuable information you have 일본야동. Keep up the good work 성인사진 you are doing here 중국야동. 무료야동
Great post 먹중소! I am actually getting 먹튀중개소 ready to across this information 먹튀검증 , is very helpful my friend 먹튀검증. Also great blog here 온라인카지노 with all of the valuable information you have 먹튀검증사이트. Keep up the good work 안전놀이터 you are doing here 안전놀이터. 검증사이트
Great post 쿨카지노! I am actually getting 쿨카지노주소ready to across this information 쿨주소, is very helpful my friend 쿨카지노새주소. Also great blog here 카지노주소 with all of the valuable information you have 쿨카지노. Keep up the good work 쿨카지노주소 you are doing here 쿨주소. 쿨카지노새주소
Great post 쿨카지노! I am actually getting 쿨카지노주소ready to across this information 바카라, is very helpful my friend 슬롯. Also great blog here 안전놀이터 with all of the valuable information you have 잭팟. Keep up the good work 메이저사이트 you are doing here 메이저놀이터. 슬롯머신
I wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. 먹튀검증 I am writing on this topic, so I think it will help a lot. I leave my blog address below. Please visit once.!
vv
mtgumc
Great post 안전놀이터! I am actually getting 안전공원ready to across this information 검증사이트, is very helpful my friend 온라인슬롯. Also great blog here 온라인카지노 with all of the valuable information you have 바카라사이트. Keep up the good work 온라인바카라 you are doing here 토토사이트.
Please let me know if you’re looking for a article writer for your site. You have some really great posts and I feel I would be a good asset. If you ever want to take some of the load off, I’d absolutely love to write some material for your blog in exchange for a link back to mine. Please send me an email if interested. Thank you 먹튀사이트 I couldn’t think of this, but it’s amazing! I wrote several posts similar to this one, but please come and see!!
xdf