我现在有这个.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.php?poll=123123变成/poll/123123/ <- (6位ID)。
我试着加入
RewriteRule ^[A-Za-z0-9-]+/([A-Za-z0-9-]+)/?$ polls.php?poll=$1 [NC,L]但是它随后尝试检测dashboard.php而不是dashboard.html。
任何帮助都将不胜感激,谢谢。
发布于 2015-03-04 12:58:09
不需要通配符,如果您正在寻找sp[特定URL,并且只更改数字“
RewriteRule ^poll/(\d+)/$ polls.php?poll=$1或者最好总是得到6位数字
RewriteRule ^poll/([0-9]{6})/$ polls.php?poll=$1那应该可以
https://stackoverflow.com/questions/28854880
复制相似问题