htaccess URL重写文件视为文件夹?

时间:2016-03-22 12:10:27

标签: php apache .htaccess mod-rewrite url-rewriting

是否有可能将网页$test = 't12345'; if(preg_match('/(?<=t)(\d+)/', $test, $matches)){ $result = $matches[0]; echo($result); } 的网址重写为此网址http://welcome.com/about.php

但已经有一些重写规则:

http://welcome.com/about/

更新

我正在寻找 Options +Indexes RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^view/([0-9]+)/([0-9]+)/([A-Za-z0-9-]+)\.html/?$ data_view.php?id=$1&cat=$2 [NC,L] RewriteRule ^([^\.]+)$ $1.php [NC,L] RewriteRule ^data/include/(.+)? Admin/$1 ErrorDocument 400 /page-not-found ErrorDocument 401 /page-not-found ErrorDocument 403 /page-not-found ErrorDocument 404 /page-not-found ErrorDocument 500 /page-not-found 进入 http://welcome.com/about.php?id=12&cat=13

1 个答案:

答案 0 :(得分:0)

有这样的话:

ErrorDocument 400 /page-not-found
ErrorDocument 401 /page-not-found
ErrorDocument 403 /page-not-found
ErrorDocument 404 /page-not-found
ErrorDocument 500 /page-not-found

Options +Indexes
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f

RewriteRule ^view/(\d+)/(\d+)/([A-Za-z\d-]+)\.html/?$ data_view.php?id=$1&cat=$2 [NC,L,QSA]

RewriteRule ^data/include/(.*)$ Admin/$1 [L,NC]

# rewrite /about/ or /about to /about.php
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+?)/?$ $1.php [L]