【发布时间】:2011-06-20 19:21:34
【问题描述】:
我必须用 htaccess 重写 www.url.com/opslag/view.php?visopslag=(id) 以获得更漂亮的东西 :o) 我正在创建一个论坛可能的应用程序。这就是我想要重写的内容:
我的要求是:
www.url.com/opslag/vis/id
我该怎么做?我尝试了很多不同的方法,例如:
RewriteRule ^/opslag/([^/\.]+)/?$ view.php?vis=$1 [L]
我的完整 .htaccess:
RewriteEngine On
"#Rewrite view.php?vis=id
RewriteRule ^opslag/vis/([0-9]+)$ /opslag/view.php?vis=$1 [L,R,QSA]
"#Remove index.php
"#RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /.*index\.php\ HTTP/
"#RewriteRule ^(.*)index\.php$ /$1 [R=301,L]
"#Remove /page/
"#RewriteCond %{REQUEST_FILENAME} !-f
"#RewriteCond %{REQUEST_FILENAME} !-d
"#RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [L]
【问题讨论】:
-
id是否总是数字、字母数字等?它可以包括什么? -
只有数字.. 就像 1,2,42,100,1.. 总是一个数字.. 就像 Stackoverflows 中的 url: url.com/questions/123123/ 一样