0

我正在尝试重写 URL 并使用下面提到的代码。但是我在我的页面上收到 404 错误,下面给出的除外。

   Options +FollowSymLinks
   RewriteEngine on

   rewritecond %{http_host} ^phoolwala.net [nc]
   rewriterule ^(.*)$ http://www.phoolwala.net/$1 [r=301,nc]
   #RewriteRule ^index.php?$ /phoolwala.net/? [R=301] 
   RewriteRule ^index.php?$ /? [R=301] 
   RewriteCond %{REQUEST_FILENAME} !-f
   RewriteCond %{REQUEST_FILENAME} !-d

    #below line gives error in dhtml editor
    #RewriteRule ^(.*)\.html$ $1.php [nc]

    #RewriteRule ^(.*)/$             $1.php [L]


    RewriteRule ^register/$ register.php [L]
    RewriteRule ^register$ register.php [L]


    RewriteRule ^my-account/$ my-account.php [L]
    RewriteRule ^my-account$ my-account.php [L]

    RewriteRule ^track-order/$ track-order.php [L]
    RewriteRule ^track-order$ track-order.php [L]

    RewriteRule ^edit-profile/$ edit-profile.php [L]
    RewriteRule ^edit-profile$ edit-profile.php [L]

    RewriteRule ^testimonials/$ testimonials.php [L]
    RewriteRule ^testimonials$ testimonials.php [L]

    RewriteRule ^sitemap/$ sitemap.php [L]
    RewriteRule ^sitemap$ sitemap.php [L]

    RewriteRule ^login/$ login.php [L]
    RewriteRule ^login$ login.php [L]

    RewriteRule ^my-account/$ my-account.php [L]
    RewriteRule ^my-account$ my-account.php [L]

    RewriteRule ^edit-profile/$ edit-profile.php [L]
    RewriteRule ^edit-profile$ edit-profile.php [L]

    RewriteRule ^reminders/$ reminders.php [L]
    RewriteRule ^reminders$ reminders.php [L]

    RewriteRule ^view-my-orders/$ view-my-orders.php [L]
    RewriteRule ^view-my-orders$ view-my-orders.php [L]

    RewriteRule ^order-details/$ order-details.php [L]
    RewriteRule ^order-details$ order-details.php [L]

    RewriteRule ^contact-us/$ contact-us.php [L]
    RewriteRule ^contact-us$ contact-us.php [L]

    RewriteRule ^logout/$ logout.php [L]
    RewriteRule ^logout$ logout.php [L]

    RewriteRule ^cart/$ cart.php [L]
    RewriteRule ^cart$ cart.php [L]


     RewriteRule ^international-products/(.*)/(.*)/(.*)/ international-products.php?cid=$1&id=$2&pageno=$3 [L]
     RewriteRule ^international-products/(.*)/(.*)(.*)/ international-products.php?cid=$1&id=$2&pageno=$3 [L]

    RewriteRule ^products/(.*)/(.*)/ products.php?id=$1&pageno=$2 [L]
    RewriteRule ^products/(.*)/(.*) products.php?id=$1&pageno=$2 [L]

    RewriteRule ^price/(.*)/(.*)/(.*)/ productsprice.php?from=$1&to=$2&pageno=$3 [L]
    RewriteRule ^price/(.*)/(.*)(.*)/ productsprice.php?from=$1&to=$2&pageno=$3 [L]

    RewriteRule ^page/(.*)/(.*)/ page.php?alias=$1&id=$2 [L]
    RewriteRule ^page/(.*)/(.*) page.php?alias=$1&id=$2 [L]

    RewriteRule ^international-product/(.*)/(.*)/(.*)/ international-product-details.php?cid=$1&cat=$2&id=$3 [L]
    RewriteRule ^international-product/(.*)/(.*)/(.*) international-product-details.php?cid=$1&cat=$2&id=$3 [L]

    RewriteRule ^product/(.*)/(.*)/(.*)/ product-details.php?cat=$1&alias=$2&id=$3 [L]
    RewriteRule ^product/(.*)/(.*)/(.*) product-details.php?cat=$1&alias=$2&id=$3 [L]

    RewriteRule ^search/(.*)/(.*)/(.*)/ productsearch.php?keyword=$1&cat=$2&pageno=$3 [L]
    RewriteRule ^search/(.*)/(.*)(.*)/ productsearch.php?keyword=$1&cat=$2&pageno=$3 [L]

    RewriteRule ^international/(.*)/ international.php?cid=$1 [L]
    RewriteRule ^international/(.*) international.php?cid=$1 [L]

但除了下面的代码没有任何工作请帮我更新代码。

  RewriteRule ^product/(.*)/(.*)/(.*)/ product-details.php?cat=$1&alias=$2&id=$3 [L]
  RewriteRule ^product/(.*)/(.*)/(.*) product-details.php?cat=$1&alias=$2&id=$3 [L]
4

1 回答 1

0

抱歉回复晚了,今天我也遇到了同样的问题,我有一个解决方案,我想和你分享。

不知道它是否正确,因为我是 PHP 的初学者。

products.php?id=15&pageno=2 and I require products/15/2

我收到错误是因为我发现我的页面名称之一也是 products.php,当我将其更改products/15/2product-detail/15/2并且它工作正常!!!

所以这意味着不要在 htaccess 规则中声明已经是页面名称的关键字。我认同 :)

谢谢

于 2012-12-03T19:35:21.333 回答