【发布时间】:2014-04-02 17:30:33
【问题描述】:
我一直在网上搜索,但似乎没有任何效果。我正在使用 Apache 和 Xampp 在本地工作。我创建了一个 .htaccess 文件并重写了所有以 .php 和 .html 结尾的 url 以删除扩展名,并创建了一个自定义 404 页面。一切正常。但是,现在我正在尝试重写一个看起来像
的动态 url/TotinCoblan/update/Wine?id=2
到
/TotinCoblan/update/Wine/2
我不断收到错误 500。这是我的 .htaccess 文件。据我了解,
RewriteCond %{REQUEST_FILENAME} !-f
应该避免无限循环。
任何帮助将不胜感激。
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^/update/Wine/([0-9]+)/?$ /update/Wine?id=$1 [L]
ErrorDocument 404 TotinCoblan/errors/404
【问题讨论】:
标签: php apache .htaccess mod-rewrite url-rewriting