我需要用一个相对简单的带有htaccess的URL来掩蔽一个又长又傻的php URL。例如,我需要掩饰-
http://mysite.com/index.php?this=that&this=that&whatevs=this&that=&id=5使用这个简单的URL -
http://mysite.com/mypage.php我知道php可以通过获取该页面的内容并显示它来非常容易地完成这些工作。但在我的情况下,ajax调用和其他一些东西存在一些问题。
此外,我更喜欢使用htaccess。我做了一些研究,但是htaccess代码让我很困惑。
发布于 2012-05-27 21:52:51
我擅自从mypage.php中删除了.php部分,因为它没有真正的用处,并且使url看起来不那么美观。
RewriteEngine On
RewriteBase /
RewriteRule ^mypage$ /index.php?this=that&this=that&whatevs=this&that=&id=5 [L,QSA]发布于 2012-05-27 20:59:31
所以您只希望将http://mysite.com/index.php?this=that&this=that&whatevs=this&that=&id=5重定向到http://mysite.com/mypage.php
然后使用这个RewriteRule:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} this=that&this=that&whatevs=this&that=&id=5
RewriteRule ^index.php$ http://mysite.com/mypage.php? [L,R=301]https://stackoverflow.com/questions/10767452
复制相似问题