【发布时间】:2015-03-04 21:30:30
【问题描述】:
我目前有这个 .htaccess 代码来删除 .php/.html 扩展名。
# Apache Rewrite Rules
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
# Add trailing slash to url
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !(\.[a-zA-Z0-9]{1,5}|/|#(.*))$
RewriteRule ^(.*)$ $1/ [R=301,L]
# Remove .php-extension from url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^([^\.]+)/$ $1.php
# Remove .html-extension from url
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^([^\.]+)/$ $1.html
# End of Apache Rewrite Rules
</IfModule>
我正在尝试将 poll.php 页面设置为 /poll/123123/
我尝试添加
RewriteRule ^[A-Za-z0-9-]+/([A-Za-z0-9-]+)/?$ polls.php?poll=$1 [NC,L]
但它随后会尝试检测dashboard.php 而不是dashboard.html。
任何帮助将不胜感激,谢谢。
【问题讨论】:
标签: php html .htaccess rewrite