简体   繁体   English

如何在.htaccess中使用多个URL RewriteRule

[英]how to use multiple url RewriteRule in .htaccess

this is working 这正在工作

RewriteRule ^([a-zA-Z0-9_-\s]+)-([a-zA-Z0-9_-\s]+)\.html$ detail.php?category=$1&model=$2

this is working 这正在工作

RewriteRule ^([a-zA-Z0-9_-\s]+)\.html$ brand.php?brand=$1

this is not working 这不起作用

RewriteRule ^([a-zA-Z0-9_-\s]+)\.htm$ colour.php?colour=$8

only two rule working how to use multiple rewrite rule using .htaccess 只有两个规则工作如何使用.htaccess使用多个重写规则

if i use like this ^colour/([a-zA-Z0-9_-\\s]+)\\.htm$ colour.php?colour=$1 then it is working with out colour/ this it is not working 如果我使用这样的^colour/([a-zA-Z0-9_-\\s]+)\\.htm$ colour.php?colour=$1则表示没有colour/这不起作用

This problem seems to be due to enabling of MultiViews . 此问题似乎是由于启用了MultiViews Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and and makes Apache server match extensions of files. Option的MultiViewsApache's content negotiation module ,该Apache's content negotiation modulemod_rewrite之前运行,并使Apache服务器匹配文件扩展名。 So /file can be in URL but it will serve /file.php . 因此/file可以位于URL中,但它将提供/file.php

To disable this use this line at top of your .htaccess: 要禁用此功能,请在.htaccess顶部使用以下行:

Options -MultiViews

RewriteEngine On
RewriteBase /

RewriteRule ^colour/([\w\s-]+)\.htm$ colour.php?colour=$1 [L,QSA,NC]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM