مرجع پارسی MyBB

نسخه‌ی کامل: تبدیل صفحات از PHP به HTML
شما درحال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب‌بندی مناسب.
صفحه‌ها: 1 2 3 4
چگونه صفحات از PHP به HTML تبدیل می شوند؟


ابتدا دلیل این کار:
1- صفحات HTML نسبت به PHP در موتورهای جست و جوگر بهتر ایندکس میشوند.
2- با این امکان میتونید کاری کنید که عنوان تاپیک همان URL تاپیک باشه، این هم در SEO موثر هست!

کنترل پنل مدیریت > پیکربندی > Server and Optimization Options
قسمت Enable search engine friendly URLs را Enable کنید.
سپس محتوای فایل htaccess.txt که در پک مای بی بی هست رو در فایل .htaccess واقع در دایرکتوری اصلی فروم اضافه کنید.

نمونه کد:

کد php:
#

# MyBB "search engine friendly" URL rewrites

# - Note, for these to work with MyBB please make sure you have

#   the setting enabled in the Admin CP and you have this file

#   named .htaccess

#

<IfModule mod_rewrite.c>

    
RewriteEngine on

    RewriteRule 
^forum-([0-9]+).html forumdisplay.php?fid=$[L,QSA]

    
RewriteRule ^forum-([0-9]+)-page-([0-9]+).html forumdisplay.php?fid=$1&page=$[L,QSA]



    
RewriteRule ^thread-([0-9]+).html showthread.php?tid=$[L,QSA]

    
RewriteRule ^thread-([0-9]+)-page-([0-9]+).html showthread.php?tid=$1&page=$[L,QSA]

    
RewriteRule ^thread-([0-9]+)-lastpost.html showthread.php?tid=$1&action=lastpost [L,QSA]

    
RewriteRule ^thread-([0-9]+)-nextnewest.html showthread.php?tid=$1&action=nextnewest [L,QSA]

    
RewriteRule ^thread-([0-9]+)-nextoldest.html showthread.php?tid=$1&action=nextoldest [L,QSA]

    
RewriteRule ^thread-([0-9]+)-newpost.html showthread.php?tid=$1&action=newpost [L,QSA]

    
RewriteRule ^thread-([0-9]+)-post-([0-9]+).html showthread.php?tid=$1&pid=$[L,QSA]



    
RewriteRule ^post-([0-9]+).html showthread.php?pid=$[L,QSA]



    
RewriteRule ^announcement-([0-9]+).html announcements.php?aid=$[L,QSA]



    
RewriteRule ^user-([0-9]+).html member.php?action=profile&uid=$[L,QSA]



    
RewriteRule ^calendar-([0-9]+).html calendar.php?calendar=$[L,QSA]

    
RewriteRule ^calendar-([0-9]+)-year-([0-9]+).html calendar.php?action=yearview&calendar=$1&year=$[L,QSA]

    
RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+).html calendar.php?calendar=$1&year=$2&month=$[L,QSA]

    
RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+).html calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$[L,QSA]

    
RewriteRule ^calendar-([0-9]+)-week-(n?[0-9]+).html calendar.php?action=weekview&calendar=$1&week=$[L,QSA]



    
RewriteRule ^event-([0-9]+).html calendar.php?action=event&eid=$[L,QSA

منبع: MS > GreyWolf & ojooobe
نقل‌قول: سپس محتوای فایل htaccess.txt که در پک مای بی بی هست رو در فایل .htaccess واقع در دایرکتوری اصلی فروم اضافه کنید.
من متوجه این جمله تون نمی شم ؛ هم در پک مای بی بی و هم در دایرکتوری فروم فقط همین فایل htaccess.txt وجود داره
این قسمت نارنجی از کجا اومد ؟
دوستان میشه بیشتر توضیح بدید...

من کدهای پست اول رو به فایل htaccess که توی دامنه اصلی مای بی بی است گذاشتم (توی forums.serialnama.com)

و اون گزینه رو هم Enable کردم ولی بازم لینک ها طولانی هستن!

چیکار باید بکنم؟
طولانی بودن لینک ها به دلیل نصب Googleseo استWink
سلام و درود به همه مدیران عزیز
من کاری رو که گفتیتد انجام دادم ولی مشکلی دارم بعد از انجام کار لینک ها درست میشه ولی وقتی روش کلیک میکنم میگه چنین صفحه ای وجود نداره
کد:
The requested URL /thread-29-lastpost.html was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2 Server at forum.cmsnews.ir Port 80

لینک قبل از تنظیمات این بوده showthread.php?tid=29 ولی حالا شده این thread-29-lastpost.html همچی درسته ولی صفحه باز نمیشه ؟
ممنون میشم راهنمایی کنید
(۱۳۸۹/۴/۲۵، ۰۰:۰۲:۱۸ صبح)tarrahan نوشته است: [ -> ]سلام و درود به همه مدیران عزیز
من کاری رو که گفتیتد انجام دادم ولی مشکلی دارم بعد از انجام کار لینک ها درست میشه ولی وقتی روش کلیک میکنم میگه چنین صفحه ای وجود نداره
کد:
The requested URL /thread-29-lastpost.html was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Apache/2 Server at forum.cmsnews.ir Port 80

لینک قبل از تنظیمات این بوده showthread.php?tid=29 ولی حالا شده این thread-29-lastpost.html همچی درسته ولی صفحه باز نمیشه ؟
ممنون میشم راهنمایی کنید
مشکل باید مربوط به .htaccess باشد.
فایل خودتون رو اینجا پیوست میکنید
دوستان میتونند فایل پیوست رو آپلود کنند و استفاده کنند به جای ساختن فایل کدهای زیر
کد:
#

# MyBB "search engine friendly" URL rewrites
# - Note, for these to work with MyBB please make sure you have
#   the setting enabled in the Admin CP and you have this file
#   named .htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^forum-([0-9]+).html forumdisplay.php?fid=$1 [L,QSA]
    RewriteRule ^forum-([0-9]+)-page-([0-9]+).html forumdisplay.php?fid=$1&page=$2 [L,QSA]


    RewriteRule ^thread-([0-9]+).html showthread.php?tid=$1 [L,QSA]

    RewriteRule ^thread-([0-9]+)-page-([0-9]+).html showthread.php?tid=$1&page=$2 [L,QSA]

    RewriteRule ^thread-([0-9]+)-lastpost.html showthread.php?tid=$1&action=lastpost [L,QSA]

    RewriteRule ^thread-([0-9]+)-nextnewest.html showthread.php?tid=$1&action=nextnewest [L,QSA]

    RewriteRule ^thread-([0-9]+)-nextoldest.html showthread.php?tid=$1&action=nextoldest [L,QSA]

    RewriteRule ^thread-([0-9]+)-newpost.html showthread.php?tid=$1&action=newpost [L,QSA]

    RewriteRule ^thread-([0-9]+)-post-([0-9]+).html showthread.php?tid=$1&pid=$2 [L,QSA]



    RewriteRule ^post-([0-9]+).html showthread.php?pid=$1 [L,QSA]



    RewriteRule ^announcement-([0-9]+).html announcements.php?aid=$1 [L,QSA]



    RewriteRule ^user-([0-9]+).html member.php?action=profile&uid=$1 [L,QSA]



    RewriteRule ^calendar-([0-9]+).html calendar.php?calendar=$1 [L,QSA]

    RewriteRule ^calendar-([0-9]+)-year-([0-9]+).html calendar.php?action=yearview&calendar=$1&year=$2 [L,QSA]

    RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+).html calendar.php?calendar=$1&year=$2&month=$3 [L,QSA]

    RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+).html calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4 [L,QSA]

    RewriteRule ^calendar-([0-9]+)-week-(n?[0-9]+).html calendar.php?action=weekview&calendar=$1&week=$2 [L,QSA]



    RewriteRule ^event-([0-9]+).html calendar.php?action=event&eid=$1 [L,QSA]
دوستایی که مشکل دارن
به نظر من که این کد کاملتره بعد از انجام مرحله اول محتویات .htaccess رو پاک کنید و این کد رو کپی کنید:
کد:
Options -MultiViews +FollowSymlinks -Indexes

#
# If mod_security is enabled, attempt to disable it.
# - Note, this will work on the majority of hosts but on
#   MediaTemple, it is known to cause random Internal Server
#   errors. For MediaTemple, please remove the block below
#
<IfModule mod_security.c>
    # Turn off mod_security filtering.
    SecFilterEngine Off

    # The below probably isn't needed, but better safe than sorry.
    SecFilterScanPOST Off
</IfModule>

#
# MyBB "search engine friendly" URL rewrites
# - Note, for these to work with MyBB please make sure you have
#   the setting enabled in the Admin CP and you have this file
#   named .htaccess
#
<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteRule ^forum-([0-9]+)\.html$ forumdisplay.php?fid=$1 [L,QSA]
    RewriteRule ^forum-([0-9]+)-page-([0-9]+)\.html$ forumdisplay.php?fid=$1&page=$2 [L,QSA]

    RewriteRule ^thread-([0-9]+)\.html$ showthread.php?tid=$1 [L,QSA]
    RewriteRule ^thread-([0-9]+)-page-([0-9]+)\.html$ showthread.php?tid=$1&page=$2 [L,QSA]
    RewriteRule ^thread-([0-9]+)-lastpost\.html$ showthread.php?tid=$1&action=lastpost [L,QSA]
    RewriteRule ^thread-([0-9]+)-nextnewest\.html$ showthread.php?tid=$1&action=nextnewest [L,QSA]
    RewriteRule ^thread-([0-9]+)-nextoldest\.html$ showthread.php?tid=$1&action=nextoldest [L,QSA]
    RewriteRule ^thread-([0-9]+)-newpost\.html$ showthread.php?tid=$1&action=newpost [L,QSA]
    RewriteRule ^thread-([0-9]+)-post-([0-9]+)\.html$ showthread.php?tid=$1&pid=$2 [L,QSA]

    RewriteRule ^post-([0-9]+)\.html$ showthread.php?pid=$1 [L,QSA]

    RewriteRule ^announcement-([0-9]+)\.html$ announcements.php?aid=$1 [L,QSA]

    RewriteRule ^user-([0-9]+)\.html$ member.php?action=profile&uid=$1 [L,QSA]

    RewriteRule ^calendar-([0-9]+)\.html$ calendar.php?calendar=$1 [L,QSA]
    RewriteRule ^calendar-([0-9]+)-year-([0-9]+)\.html$ calendar.php?action=yearview&calendar=$1&year=$2 [L,QSA]
    RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)\.html$ calendar.php?calendar=$1&year=$2&month=$3 [L,QSA]
    RewriteRule ^calendar-([0-9]+)-year-([0-9]+)-month-([0-9]+)-day-([0-9]+)\.html$ calendar.php?action=dayview&calendar=$1&year=$2&month=$3&day=$4 [L,QSA]
    RewriteRule ^calendar-([0-9]+)-week-(n?[0-9]+)\.html$ calendar.php?action=weekview&calendar=$1&week=$2 [L,QSA]

    RewriteRule ^event-([0-9]+)\.html$ calendar.php?action=event&eid=$1 [L,QSA]

    <IfModule mod_env.c>
        SetEnv SEO_SUPPORT 1
    </IfModule>
</IfModule>

#
# If Apache is compiled with built in mod_deflade/GZIP support
# then GZIP Javascript, CSS, HTML and XML so they're sent to
# the client faster.
#
<IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE application/x-javascript text/css text/html text/xml
</IfModule>
درود
وقتی که این کار رو انجام دادیم , آدرس های قبلی به آدرس جدید منتقل میشود ؟ به عبارت دیگه آیا انجام این کار نیاز به ایندکس شدن دوباره دارد ؟ و انجمن در هر شرایطی که استفاده کند , مفید هست ؟ ( مثلا با گذشت 2 سال از عمر انجمن )

همواره مفید است.
صفحه‌ها: 1 2 3 4