ผมจะเขียน mod rewrite index.php ให้เป็น index.html ยังไง ช่วยหน่อย

เริ่มโดย clickfive, 01 มีนาคม 2012, 14:28:48

หัวข้อก่อนหน้า - หัวข้อถัดไป

0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้

ดีน วินเชสเตอร์

อ้างถึงจาก: หนุ่มบ้านโคก ใน 01 มีนาคม 2012, 18:25:48
ลองแล้วครับแต่มันใช้ไม่ได้ คือผมเขียนระบบแยกไว้ในเว็บที่ทำด้วย wp มันสามารถเพิ่มโค้ดเข้าไปใน ไฟล์ .HTACCESS ของ wp ได้เลยใช่มั้ยครับ :P

งั้นคงต้องเลือก Copy มาเฉพาะส่วนที่ต้องใช้อ่ะครับ

หนุ่มบ้านโคก

ขออนุญาติพี่เจ้าของกระทู้น่ะครับ
hllp://www.xxxx.com/search.php?search=xxx&send=yyyy
ซึ่งที่ต้องการคือ
hllp://www.xxxx.com/search/yyyy/xxx.html
ผมแทรกใน .htaccess ของ wp น่ะครับ
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

# END WordPress
php_flag register_globals on
RewriteRule ^([^/]*)/([^/]*)\.html$ /search.php?search=$2&send=$1 [L]
ผมเขียนอย่างนี้ถูกมั้ยครับ
:P

bot2o

อ้างถึงจาก: หนุ่มบ้านโคก ใน 01 มีนาคม 2012, 18:49:55
ขออนุญาติพี่เจ้าของกระทู้น่ะครับ
hllp://www.xxxx.com/search.php?search=xxx&send=yyyy
ซึ่งที่ต้องการคือ
hllp://www.xxxx.com/search/yyyy/xxx.html
ผมแทรกใน .htaccess ของ wp น่ะครับ
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

# END WordPress
php_flag register_globals on
RewriteRule ^([^/]*)/([^/]*)\.html$ /search.php?search=$2&send=$1 [L]
ผมเขียนอย่างนี้ถูกมั้ยครับ
:P

ผมลองมั่วอะนะ ไม่ได้ check

RewriteRule ^search/([^/]*)/([^/]*)\.html$ /search.php?search=$2&send=$1 [L]

หนุ่มบ้านโคก

อ้างถึงจาก: bot2o ใน 01 มีนาคม 2012, 19:01:33
อ้างถึงจาก: หนุ่มบ้านโคก ใน 01 มีนาคม 2012, 18:49:55
ขออนุญาติพี่เจ้าของกระทู้น่ะครับ
hllp://www.xxxx.com/search.php?search=xxx&send=yyyy
ซึ่งที่ต้องการคือ
hllp://www.xxxx.com/search/yyyy/xxx.html
ผมแทรกใน .htaccess ของ wp น่ะครับ
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

# END WordPress
php_flag register_globals on
RewriteRule ^([^/]*)/([^/]*)\.html$ /search.php?search=$2&send=$1 [L]
ผมเขียนอย่างนี้ถูกมั้ยครับ
:P

ผมลองมั่วอะนะ ไม่ได้ check

RewriteRule ^search/([^/]*)/([^/]*)\.html$ /search.php?search=$2&send=$1 [L]
มันไม่ยอม rewrite ให้เลยครับ :P

ohmohm

อ้างถึงจาก: หนุ่มบ้านโคก ใน 01 มีนาคม 2012, 19:44:48
อ้างถึงจาก: bot2o ใน 01 มีนาคม 2012, 19:01:33
อ้างถึงจาก: หนุ่มบ้านโคก ใน 01 มีนาคม 2012, 18:49:55
ขออนุญาติพี่เจ้าของกระทู้น่ะครับ
hllp://www.xxxx.com/search.php?search=xxx&send=yyyy
ซึ่งที่ต้องการคือ
hllp://www.xxxx.com/search/yyyy/xxx.html
ผมแทรกใน .htaccess ของ wp น่ะครับ
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

# END WordPress
php_flag register_globals on
RewriteRule ^([^/]*)/([^/]*)\.html$ /search.php?search=$2&send=$1 [L]
ผมเขียนอย่างนี้ถูกมั้ยครับ
:P

ผมลองมั่วอะนะ ไม่ได้ check

RewriteRule ^search/([^/]*)/([^/]*)\.html$ /search.php?search=$2&send=$1 [L]
มันไม่ยอม rewrite ให้เลยครับ :P
ผมว่าต้องเอา
RewriteRule ^search/([^/]*)/([^/]*)\.html$ /search.php?search=$2&send=$1 [L]
ไปอยู่ก่อนบรรทัด
RewriteCond %{REQUEST_FILENAME} !-f
นะผมว่า

อ้างถึงจาก: clickfive ใน 01 มีนาคม 2012, 16:15:09
แล้วผมต้องการให้มัน [R] Redirect you can add an =301 or =302 to change the type.

ผมจะต้องใส่ตัว [R] ตรงไหนอ่ะครับ ถ้าใส่ด้านหลัง ตามด้านล่างนี้ มันก็ Redirect ไปที่ index.php

ที่ต้องการคือ index.php เปลี่ยนเป็น(พร้อม Redirect) xn--b3c6aejtbwl6hb3e2jla.html

RewriteRule ^xn--b3c6aejtbwl6hb3e2jla\.html /index\.php [R]
ใส่ [R] ข้างหลัง และถ้าอยาก index.php ให้ Redirect ไป xn--b3c6aejtbwl6hb3e2jla.html ก็น่าจะทำแบบนี้ได้
RewriteRule ^index\.php$ /xn--b3c6aejtbwl6hb3e2jla.html [R]

อ้างถึงจาก: หนุ่มบ้านโคก ใน 01 มีนาคม 2012, 16:21:03
เกิดความรู้ ถามต่อแล้วถ้าอย่างเป็นหน้าค้นหาข้อมูลละครับ

เวลาค้นมันจะขึ้น
www.xxxxx.com/search.php?search=ปลา&send=ค้นหา
แยากเปลี่ยนให้มันเป็น
www.xxxxx.com/search/ปลา.html
อย่างนี้ทำได้มั้ยครับ
:P
แบบนี้ก็น่าจะได้แล้วมั่ง
RewriteRule ^search/([^/]*)\.html$ /search.php?search=$1&send=ค้นหา

ทำค้นหาอยู่หรือครับ http://www.thaiseoboard.com/index.php/topic,260435.0.html

แถมๆ http://css-tricks.com/how-to-redirect-indexhtml-to-indexphp/