简体   繁体   English

阻止htaccess重写子文件夹

[英]stop htaccess from rewrite in subfolder

i have problem with htaccess 我对htaccess有问题

i make convert url to html from php 我将php的url转换为html

but if any subfolder in domain all convert url to html 但是如果域中有任何子文件夹都将url转换为html

i just need domain conert url and not in any subfolder 我只需要域conert url,而不需要任何子文件夹

this is my code 这是我的代码

RewriteCond %{REQUEST_URI} !^(.*)form.php(.*)$
RewriteCond %{THE_REQUEST} ^[A-Z]+\s([^\s]+)\.php\s
RewriteCond %{REQUEST_URI} !^(.*)form.php(.*)$
RewriteRule .* %1.html [R=301,L]
RewriteRule ^(.*)\.html$ $1.php
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^.*$ - [L]
RewriteRule ^index.php$ http://%{http_host} [R=301,L]

Change your rules to: 将规则更改为:

RewriteCond %{REQUEST_URI} !^(.*)form.php(.*)$
RewriteCond %{REQUEST_URI} !^(.*)sitemap\.xml(.*)$
RewriteCond %{THE_REQUEST} ^[A-Z]+\s([^/]+)\.php\s
RewriteRule .* %1.html [R=301,L]
RewriteRule ^([^/]*)\.html$ $1.php
RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^.*$ - [L]
RewriteRule ^index.php$ http://%{http_host} [R=301,L]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM