简体   繁体   English

内容不会隐藏在url-rewrite url上,而是在普通网址上

[英]Content isn't hidden on url-rewrite url, but is on normal url

I am using this code to prevent a <div> element from being displayed on the page example.php: 我使用此代码来阻止<div>元素显示在页面example.php上:

<?php if($_SERVER["SCRIPT_NAME"] !== '/example.php') { ?>
<div>Example</div>
<?php } ?>

Using this code in .htaccess , I can change the page name from example.php to example : .htaccess使用此代码,我可以将example.php的页面名称更改为example

RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule !.*\.php$ %{REQUEST_FILENAME}.php [QSA,L]

When I visit http://website.com/example.php , the <div> element does not show - but when I visit http://website.com/example , it does - how can I stop this? 当我访问http://website.com/example.php时<div>元素没有显示 - 但是当我访问http://website.com/example时 ,它确实 - 我怎么能阻止它?

use strpos() :- 使用strpos() : -

<?php if(strpos($_SERVER["SCRIPT_NAME"], 'example') === false) { ?>
   <div>Example</div>
<?php } ?>

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

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