سؤال

وأريد أن إعادة توجيه جميع طلبات index.html و| فب | PHP5 إلى HTTP: //www.domain تغيير .com.eg / استخدام mod_rewrite وولقد نسخ رمز من كتاب عن محرك البحث الأمثل مع PHP حرفيا، ثم أضاف في الخيار PHP5، ولكنه لا يعمل. هذا هو بلدي ملف هتكس الكامل:

RewriteEngine On

#translate any .html ending into .php5
RewriteRule ^(.*)\.html$ /$1\.php5

RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php5|php|html)\HTTP
RewriteRule ^(.*)index\.(php5|php|html)$ /$1 [R=301,L]

#change / for ?
RewriteRule ^(.*)\.html/(.*)$ /$1\.html?$2

#strip .html from search res page
RewriteRule ^(.*)search/(.*)$ /$1search_results\.html/search=$2

#translate product details link from search res page
RewriteRule ^products/(.*)/(.*)/(.*)$ /product_details.php5?category=$1&title=$2&id=$3 [L]

#Translate products/psorisis/chamomile-skin-cream-P[x] to productview.php5?id=1
RewriteRule ^products/.*-P([0-9]+) /productview.php5?id=$1 [L]

وأنا دونو ما هو الخطأ في ذلك، والباقي يعمل بشكل جيد ومدهش. أي شخص لديه أي أفكار؟

هل كانت مفيدة؟

المحلول

واعتقد انها لRerwriteCond بك ينتهي \HTTP.

وتغييره إلى:

RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php5|php|html)
RewriteRule ^(.*)index\.(php5|php|html)$ /$1 [R=301,L]

إذا كنت تريد أن تتناسب مع HTTP من THE_REQUEST ثم وضع مسافة هناك

RewriteCond %{THE_REQUEST} ^GET\ .*/index\.(php5|php|html)\ HTTP
RewriteRule ^(.*)index\.(php5|php|html)$ /$1 [R=301,L]
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top