我创建了一个包含2个iframe的网站,第一个iframe播放了歌曲,第二个iframe拥有了该网站。这是我的index.php文件:
<?php
$base_url = 'http://www.mywebsite.com/site/';
?>
<iframe src="<?php echo $base_url; ?>music.php" frameborder="0" width="960px" height="1px"></iframe>
<?php
$page = $_GET['params'];
switch ($page) {
case 'home':
$page = 'home.php';
break;
case 'contact':
$page = 'contact.php';
break;
}
?>
<iframe src="<?php echo $base_url; ?><?php echo $page ?>" frameborder="0" width="100%" height="100%"></iframe>
这是我的.htaccess
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ site/index.php?params=$1
它工作正常,但我需要的是:
当用户尝试访问http://www.mywebsite.com/contact时,我需要为我的switch语句获取此“联系人”,并清除http://www.mywebsite.com的网址
模拟:
提前致谢!
您可以执行前3个步骤
RewriteRule ^contact$ /contact.php?params=contact [L,QSA]
如果您将其添加到已有规则之前。但是您不能将URL“清除”到http://www.mywebsite.com/
,因为从那时开始URL将无法区分site/index.php?params=home
。
对于任何“联系”页面,然后:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILEMAME} !-d
RewriteCond %{REQUEST_FILENAME}.php -f
RewriteRule ^(.+)$ /$1.php?params=$1 [L,QSA]
您还需要确保Multiviews
已将其关闭:
Options Multiviews
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句