当前位置: 动力学知识库 > 问答 > 编程问答 >

regex - htaccess forward but does not uses parameter

问题描述:

I have a quite simple rewrite rule, it works meaning the rewrite works but the parameter does not reach the destination page.

Each page has a section, title and a id.

The url has dashes in the name and I use a underscore separator to separate the id.

  • The section name is hypnose

  • The title is Hoe-werkt-hypnose

  • The id is 4

The rewrite rule:

RewriteRule ^hypnose/([^/.]+)_([^/.]+).php$ hypnose.php?title=$1&id=$2 [L]

The url that i'm using

hypnose/Hoe-werkt-hypnose_4.php

网友答案:

You need to turn MultiViews option off:

Options -MultiViews
RewriteEngine On

RewriteRule ^hypnose/([^/_]+)_([^/.]+)\.php$ hypnose.php?title=$1&id=$2 [L,QSA,NC]

Option MultiViews is used by Apache's content negotiation module that runs before mod_rewrite and makes Apache server match extensions of files. So /file can be in URL but it will serve /file.php.

分享给朋友:
您可能感兴趣的文章:
随机阅读: