Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
435 views
in Technique[技术] by (71.8m points)

.htaccess - htaccess redirect everything except .htm when it's not in a particular folder

Currently I have the below rules in my htaccess file. All files should redirect except if they have .htm or .html extensions

RewriteRule .(htm|html)$ - [NC,L]
RewriteRule ^([A-Za-z0-9-+_./]+)/?$  index.php?page=$1&%{QUERY_STRING}

Now the problem is that tinyMce also has files with .htm, and in that case, the redirect should take place.

So, I want to prevent redirection on .htm files except when the folderstructure/url somewhere contains "tinyMCE" in it... How can I do this?

question from:https://stackoverflow.com/questions/65937284/htaccess-redirect-everything-except-htm-when-its-not-in-a-particular-folder

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Based on your shown samples could you please try following. Trying to fix OP's attempt here, please make sure to clear your browser cache before testing your URLs.

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]


2nd solution: Or try with following rules too, please try to put ONLY one set of rules either above OR these ones at a time.

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...