Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.htaccess htaccess重定向除.htm之外的所有内容,当它';它不在特定文件夹中_.htaccess_Redirect_Mod Rewrite_Url Rewriting_Friendly Url - Fatal编程技术网

.htaccess htaccess重定向除.htm之外的所有内容,当它';它不在特定文件夹中

.htaccess htaccess重定向除.htm之外的所有内容,当它';它不在特定文件夹中,.htaccess,redirect,mod-rewrite,url-rewriting,friendly-url,.htaccess,Redirect,Mod Rewrite,Url Rewriting,Friendly Url,目前,我的htaccess文件中有以下规则。 除扩展名为.htm或.html外,所有文件都应重定向 RewriteRule \.(htm|html)$ - [NC,L] RewriteRule ^([A-Za-z0-9-+_./]+)/?$ index.php?page=$1&%{QUERY_STRING} 现在的问题是tinyMce也有.htm文件,在这种情况下,应该进行重定向 因此,我想防止在.htm文件上重定向,除非folderstructure/url某处包含“tinyMCE

目前,我的htaccess文件中有以下规则。 除扩展名为.htm或.html外,所有文件都应重定向

RewriteRule \.(htm|html)$ - [NC,L]
RewriteRule ^([A-Za-z0-9-+_./]+)/?$  index.php?page=$1&%{QUERY_STRING}
现在的问题是tinyMce也有.htm文件,在这种情况下,应该进行重定向

因此,我想防止在.htm文件上重定向,除非folderstructure/url某处包含“tinyMCE”。。。
我怎样才能做到这一点呢?

根据您展示的样品,请尝试以下内容。试图修复OP在此处的尝试,请确保在测试URL之前清除浏览器缓存

RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !tinyMCE [NC]
RewriteRule ^([A-Za-z0-9-+_./]+)/?$  index.php?page=$1&%{QUERY_STRING} [L]


第二种解决方案:或尝试使用以下规则,请尝试一次只在上面或这些规则中放置一组规则

RewriteEngine ON
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^((?!tinyMCE)[A-Za-z0-9-+_./]+)/?$  index.php?page=$1&%{QUERY_STRING} [L]

嗨,谢谢你的帮助。。。此解决方案不会重定向除tinyMCE文件夹中的请求以外的所有请求吗?而tinyMCE文件夹之外的其他.htm文件也应防止redirecting@Bernard,不客气。既然html文件已经存在于后端,那么无论如何它都不会捕获这些规则:)所以请尝试一下,并让我知道这是否对您有帮助?谢谢,它似乎做得很好:)