htaccess不能按照明智的规则定义

时间:2016-04-02 15:25:11

标签: php apache .htaccess mod-rewrite

我对htaccess的了解说,一旦使用了 [L] 标志,规则就会终止,不再执行其他规则。但是,在我将以下规则添加到我当前的htaccess之后,这里不知道为什么规则不起作用。

 #### Redirect all non-file & non-directory url to Results.php ####
 RewriteCond %{SCRIPT_FILENAME} !-d
 RewriteCond %{SCRIPT_FILENAME} !-f
 RewriteRule ^.*$ ./Results.php [L]

所有有效网址,例如Job-Details.php也会重定向到Results.php脚本。

注意:我已经在重新启动wamp server&的所有服务后进行了检查清除缓存。

编辑1: - 我花了超过1天的阅读后知道我无法解释我想要的解决方案。为此道歉。

现在,明确的想法是,在Job-Details.php url重写后,url变得像 http://domain.com/7997我希望,默认情况下,此网址不应转到Results.php,但它不存在文件/目录名称&应该使用Job-Details.php脚本代替Results.php

我尝试使用以下代码但没有正面结果。

Rewritecond %{REQUEST_URI} [^0-9/]$

我该怎么办?有专家建议吗?

我完整的htaccess

Options +FollowSymLinks

### Start rewrite and set basedir
RewriteEngine on
Rewritebase /Domain.com/

########### Redirect all non-file & non-directory url to Results.php ############
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^.*$ ./Results.php [L]

########### Remove php extension ####################
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]

########### Job detail page extension remove ####################
RewriteCond %{THE_REQUEST} Job\-Details\.php\?Job_ID\=(\d+) [NC]
RewriteRule ^ %1? [R=301,L,NE]

########### Result page extension ####################
#RewriteCond %{THE_REQUEST} Results\.php\?url\=([A-Za-z0-9-_]+) [NC]
#RewriteRule ^ %1? [R=301,L,NE]

我已尝试搜索此行为背后的逻辑,但无法找到任何或我可能搜索错误的分析。

0 个答案:

没有答案