RewriteEngine On

# إزالة www وتحويل إلى https
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

# تحويل كل http إلى https
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]

ErrorDocument 401 https://f-a-z.sa/404/الصفحة-غير-موجودة
ErrorDocument 402 https://f-a-z.sa/404/الصفحة-غير-موجودة
ErrorDocument 403 https://f-a-z.sa/404/الصفحة-غير-موجودة
ErrorDocument 404 https://f-a-z.sa/404/الصفحة-غير-موجودة
ErrorDocument 500 https://f-a-z.sa/404/الصفحة-غير-موجودة

#RewriteRule ^(.*\.js) gzip.php?type=js&file=$1
#RewriteRule ^(.*\.css) gzip.php?type=css&file=$1

#must enable this httpd.conf
#LoadModule filter_module modules/mod_filter.so
#LoadModule deflate_module modules/mod_deflate.so

<IfModule mod_deflate.c>
    # Compress HTML, CSS, JavaScript, Text, XML and fonts
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE text/javascript
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/atom+xml
    AddOutputFilterByType DEFLATE application/x-font-ttf
    AddOutputFilterByType DEFLATE application/font-woff
    AddOutputFilterByType DEFLATE application/font-woff2
    AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
    AddOutputFilterByType DEFLATE image/svg+xml
    AddOutputFilterByType DEFLATE image/x-icon

    # Exclude images and other binary files from compression
    SetEnvIfNoCase Request_URI \
    \.(?:gif|jpe?g|png|exe|zip|gz|bz2|rar|tar)$ no-gzip dont-vary
</IfModule>


################ start caching #####################
<IfModule mod_expires.c>
  ExpiresActive On

 # Images
  ExpiresByType image/jpeg "access plus 1 year"
  ExpiresByType image/gif "access plus 1 year"
  ExpiresByType image/png "access plus 1 year"
  ExpiresByType image/webp "access plus 1 year"
  ExpiresByType image/svg+xml "access plus 1 year"
  ExpiresByType image/x-icon "access plus 1 year"

  # Video
  ExpiresByType video/webm "access plus 1 year"
  ExpiresByType video/mp4 "access plus 1 year"
  ExpiresByType video/mpeg "access plus 1 year"

  # Fonts
  ExpiresByType font/ttf "access plus 1 year"
  ExpiresByType font/otf "access plus 1 year"
  ExpiresByType font/woff "access plus 1 year"
  ExpiresByType font/woff2 "access plus 1 year"
  ExpiresByType application/font-woff "access plus 1 year"

  # CSS, JavaScript
  ExpiresByType text/css "access plus 1 year"
  ExpiresByType text/javascript "access plus 1 year"
  ExpiresByType application/javascript "access plus 1 year"

  # Others
  ExpiresByType application/pdf "access plus 1 year"
  ExpiresByType image/vnd.microsoft.icon "access plus 1 year"
</IfModule>


################ end caching #####################




#routers

RewriteRule ^400/(.+) 404.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^401/(.+) 404.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^403/(.+) 404.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^404/(.+) 404.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^500/(.+) 404.php?comp_id=1&page_title=$1 [NC,L]




RewriteRule ^ar ../ar/index.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^logout_members logout_members.php?comp_id=1&page_title=1 [NC,L]


#member CP

RewriteRule ^members_personal ajax_members_personal.php?comp_id=1 [NC,L]


RewriteRule ^cp_index_members users/members_cp.php?comp_id=1&page_title=1 [NC,L]
RewriteRule ^members members_login.php?comp_id=1&page_title=1 [NC,L]
RewriteRule ^account new_account.php?comp_id=1&page_title=1 [NC,L]

RewriteRule ^login_all login_all.php?comp_id=1&page_title=1 [NC,L]
RewriteRule ^login_teachers login_teachers.php?comp_id=1&page_title=1 [NC,L]
RewriteRule ^login_students login_students.php?comp_id=1&page_title=1 [NC,L]
RewriteRule ^login_guides login_guides.php?comp_id=1&page_title=1 [NC,L]
RewriteRule ^login_fathers login_fathers.php?comp_id=1&page_title=1 [NC,L]

RewriteRule ^login login.php?comp_id=1&page_title_en=1 [NC,L]
RewriteRule ^logout logout.php?comp_id=1&page_title_en=1 [NC,L]


RewriteRule ^logout logout.php?comp_id=1&page_title=1 [NC,L]
RewriteRule ^students_registeration students_registeration.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^employement employement.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^our_staff our_staff.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^health_care health_care.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^students_work students_work.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^achievements acheivements.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^school_calendar school_calendar.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^employment employment.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^checkout checkout.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^billing billing.php?comp_id=1&page_title=$1 [NC,L]




RewriteRule ^/ index.php?comp_id=1 [NC,L]
RewriteRule ^index/(.+) index.php?comp_id=1&page_title=$1 [NC,L]



RewriteRule ^clients/(.+) clients.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^about/(.+) about.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^contact/(.+) contact.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^manager_word/(.+) manager_word.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^managment/(.+) managment.php?comp_id=1&page_title=$1 [NC,L]


RewriteRule ^branches/(.+) branches.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^bank_accounts/(.+) bank_accounts.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^directors_board/(.+) directors_board.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^directors_credit_letter/(.+) directors_credit_letter.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^general_assembly/(.+) general_assembly.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^teamwork/(.+) teamwork.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^policies/(.+) policies.php?comp_id=1&page_title=$1 [NC,L]


RewriteRule ^roles/(.+) roles.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^assembly_minutes/(.+) assembly_minutes.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^finance_lists/(.+) finance_lists.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^quartar_finance_lists/(.+) quartar_finance_lists.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^investments_decisions/(.+) investments_decisions.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^ownership_decisions/(.+) ownership_decisions.php?comp_id=1&page_title=$1 [NC,L]



RewriteRule ^visitors_survies/(.+) visitors_survies.php?comp_id=1&page_title=$1 [NC,L]													  
RewriteRule ^clients_survies/(.+) clients_survies.php?comp_id=1&page_title=$1 [NC,L]	
RewriteRule ^employees_servies/(.+) employees_servies.php?comp_id=1&page_title=$1 [NC,L]	
RewriteRule ^volunteer_survies/(.+) volunteer_survies.php?comp_id=1&page_title=$1 [NC,L]	


RewriteRule ^visitors_survey/(.+)/(.+) visitors_survey.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^clients_survey/(.+)/(.+) clients_survey.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^employees_survey/(.+)/(.+) employees_survey.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^volunteer_survey/(.+)/(.+) volunteer_survey.php?comp_id=1&id=$1&page_title=$2 [NC,L]




RewriteRule ^visitors_survies/(.+) visitors_survies.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^clients_survies/(.+) clients_survies.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^employees_survies/(.+) employees_survies.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^volunteers_survies/(.+) volunteers_survies.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^visitors_survie/(.+)/(.+) visitors_survie.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^clients_survie/(.+)/(.+) clients_survie.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^employees_survie/(.+)/(.+) employees_survie.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^volunteers_survie/(.+)/(.+) volunteers_survie.php?comp_id=1&id=$1&page_title=$2 [NC,L]



RewriteRule ^projects/(.+) projects.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^offers/(.+) offers.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^orders/(.+) orders.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^make_orders/(.+) make_orders.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^checkout/(.+) checkout.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^checkout/(.+) checkout.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^customer_service/(.+) customer_service.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^member_activate/(.+)/(.+) member_activate.php?comp_id=1&pass=$1&email=$2 [NC,L]
RewriteRule ^forget_password/(.+) forget_password.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^reset_password/(.+)/(.+) reset_password.php?comp_id=1&reg=$1&email=$2 [NC,L]




RewriteRule ^manager_word/(.+) manager_word.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^overview/(.+) overview.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^fee/(.+) fee.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^uniform/(.+) uniform.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^admission/(.+) admission.php?comp_id=1&page_title=$1 [NC,L]


RewriteRule ^school_tour/(.+) school_tour.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^academic_facilities/(.+) academic_facilities.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^sporting_facilities/(.+) sporting_facilities.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^medical/(.+) health_care.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^canteen/(.+) canteen.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^honer_board/(.+) honer_board.php?comp_id=1&page_title=$1 [NC,L]





RewriteRule ^motion_graphic/(.+)/(.+) motion_graphic.php?comp_id=1&service_id=$1&page_title=$2 [NC,L]
RewriteRule ^web_designing/(.+)/(.+) web_designing.php?comp_id=1&service_id=$1&page_title=$2 [NC,L]
RewriteRule ^web_devloping/(.+)/(.+) Web_developing.php?comp_id=1&service_id=$1&page_title=$2 [NC,L]
RewriteRule ^motion_graphic/(.+)/(.+) motion_graphic.php?comp_id=1&service_id=$1&page_title=$2 [NC,L]
RewriteRule ^mobile_applications/(.+)/(.+) mobile_applications.php?comp_id=1&service_id=$1&page_title=$2 [NC,L]
RewriteRule ^seo/(.+)/(.+) seo.php?comp_id=1&service_id=$1&page_title=$2 [NC,L]


RewriteRule ^privacy/(.+) privacy.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^policy/(.+) policy.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^wedo/(.+) wedo.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^vision/(.+) vision.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^history/(.+) history.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^whyus/(.+) whyus.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^wedo/(.+) wedo.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^faq/(.+) faq.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^certificates/(.+) certificates.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^productionline/(.+) productionline.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^partners/(.+) partners.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^talk_about/(.+) talk_about.php?comp_id=1&page_title=$1 [NC,L]



RewriteRule ^suggessions/(.+) suggession.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^suggession_send/(.+) suggessions.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^send_survie/(.+) survie_send.php?comp_id=1&page_title=$1 [NC,L]


RewriteRule ^galleries/(.+) galleries.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^news/(.+) news.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^services_categories/(.+) services_categories.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^cources_categories/(.+) cources_categories.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^blogs/(.+) blogs.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^blogs_categories/(.+) blogs_departs.php?comp_id=1&page_title_en=$1 [NC,L]

RewriteRule ^videos/(.+) videos.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^auther/(.+) auther.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^verification/(.+) verifications.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^orders_check/(.+)/(.+) orders_check.php?comp_id=1&page_title=$1&order_id=$2 [NC,L]

RewriteRule ^events/(.+) events.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^comparisons/(.+) comparisons.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^reviews/(.+)/(.+) reviews.php?comp_id=1&depart_id=$1&page_title=$2 [NC,L]
RewriteRule ^reviews/(.+) reviews.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^galleries/(.+)/(.+) galleries.php?comp_id=1&depart_id=$1&page_title=$2 [NC,L]
RewriteRule ^galleries/(.+) galleries.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^services/(.+) services.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^consultings/(.+)/(.+) consultings.php?comp_id=1&depart_id=$1&page_title=$2 [NC,L]
RewriteRule ^sessions/(.+)/(.+) sessions.php?comp_id=1&depart_id=$1&page_title=$2 [NC,L]
RewriteRule ^courses/(.+)/(.+) cources.php?comp_id=1&depart_id=$1&page_title=$2 [NC,L]
RewriteRule ^deplomas/(.+)/(.+) deplomas.php?comp_id=1&depart_id=$1&page_title=$2 [NC,L]
RewriteRule ^whats_new/(.+)/(.+) whats_new.php?comp_id=1&depart_id=$1&page_title=$2 [NC,L]
RewriteRule ^production/(.+) production.php?comp_id=1&page_title=$1 [NC,L]



RewriteRule ^rules/(.+) rules.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^events/(.+) events.php?comp_id=1&page_title=$1 [NC,L]


RewriteRule ^search/(.+) search.php?comp_id=1&search=$1 [NC,L]


RewriteRule ^form/(.+) form.php?comp_id=1&search=$1 [NC,L]

RewriteRule ^consulting/(.+) consulting.php?&page_title=$1 [NC,L]
RewriteRule ^consulting_form/(.+) consulting_form.php?comp_id=1&page_title=$1 [NC,L]
RewriteRule ^sessions/(.+) sessions.php?&page_title=$1 [NC,L]
RewriteRule ^session_form/(.+) session_form.php?comp_id=1&page_title=$1 [NC,L]

RewriteRule ^gallery/(.+)/(.+) gallery.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^news_article/(.+)/(.+) news_article.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^project/(.+)/(.+) project.php?comp_id=1&id=$1&page_title=$2 [NC,L]

RewriteRule ^comparison/(.+)/(.+) comparison.php?comp_id=1&id=$1&page_title=$2 [L,NC,QSA]
RewriteRule ^review/(.+)/(.+) review.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^rule/(.+)/(.+) rule.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^service/(.+)/(.+) service.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^book/(.+)/(.+) book.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^consulting/(.+)/(.+) consulting.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^session/(.+)/(.+) session.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^auther/(.+)/(.+) auther.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^blog/(.+)/(.+) blog.php?comp_id=1&id=$1&page_title=$2 [NC,L]

RewriteRule ^course/(.+)/(.+) course.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^deploma/(.+)/(.+) deploma.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^video/(.+)/(.+) video.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^blog/(.+)/(.+) blog.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^page/(.+)/(.+) page.php?comp_id=1&id=$1&page_title=$2 [NC,L]


RewriteRule ^comparison_preview/(.+)/(.+) comparison_preview.php?comp_id=1&id=$1&page_title=$2 [L,NC,QSA]
RewriteRule ^review_preview/(.+)/(.+) review_preview.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^rule_preview/(.+)/(.+) rule_preview.php?comp_id=1&id=$1&page_title=$2 [NC,L]
RewriteRule ^blog_preview/(.+)/(.+) blog_preview.php?comp_id=1&id=$1&page_title=$2 [NC,L]






