htaccess重写规则冲突

时间:2014-08-27 13:17:11

标签: apache .htaccess mod-rewrite

如何重写:

http://localmachine/product.php?c=water&p=Evian

进入:

http://localmachine/water/evian

如果我加上 RewriteRule ^([A-Za-z0-9_?-]+)/([A-Za-z0-9_?-]+)(/)?$ product.php?c=$1&p=$2 [NC,L]

我想在这一行发生冲突

RewriteRule ^(index\.php)/([^-]+)-([^/]+)(/.*)?$ /$1$4?$2=$3 [L,QSA]

这是我的htaccess:

RewriteEngine On 
Options -Indexes 
Options +FollowSymLinks
<Files .htaccess>
deny from all
</Files>



# rewrite /user-options to /user.php?page=page
RewriteRule ^user/logout/? actions/handler.user.php?logout=true [NC,L]
RewriteRule ^user/?$ user.php [NC,L]



# edit shopping lists
RewriteRule ^user/liste/([0-9]+)/del(/)?$ user.php?page=edit-list&gid=$1&action=del [NC,L]
RewriteRule ^user/liste/(.+)$ user.php?page=edit-list&gid=$1 [NC,L]
RewriteRule ^user/([^/]+)/?$ user.php?page=$1 [L,QSA]

# rewrite /category to /index.php?c=category
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/?$ /index.php/?c=$1 [L,QSA]


# rewrite /category/brand-mybrand/country-mycountry/offer-yes/new-yes
# to /index.php/brand-mybrand/country-mycountry/offer-yes/new-yes?c=category
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/([^-]+.+)/?$ /index.php/$2?c=$1 [L,QSA]

# rewrite /index.php/brand-mybrand/country-mycountry/offer-yes/new-yes?c=category
# converts any /name-val/ to query parameter name=val in every rewrite
# stopping when there is no part left after /index.php
RewriteRule ^(index\.php)/([^-]+)-([^/]+)(/.*)?$ /$1$4?$2=$3 [L,QSA]


# review basket & place order
RewriteRule ^shopping-cart/actions/delete/(.*)?$ actions/handler.comanda.php?action=delcart&id=$1 [NC,L]
RewriteRule ^shopping-cart/del/(.*)/? cosuldecumparaturi.php?d=true&p=$1 [NC,L]
RewriteRule ^shopping-cart/place-order/?$ comanda.php [NC,L]
RewriteRule ^shopping-cart/preview(/)?$ cosuldecumparaturi.php [NC,L]

# rewrite ajax calls
RewriteRule ^ajax/totalShoppingCart/? ajax/totalShoppingCart.php [NC,L]


# rewrite information page
RewriteRule ^informatii/([A-Za-z0-9_?-]+)/?$ pages.php?page=$1 [NC,L]

0 个答案:

没有答案