Question

i need to mask a long, stupid php URL with a relatively simple URL with htaccess. For example, i need to mask -

http://mysite.com/index.php?this=that&this=that&whatevs=this&that=&id=5

with this simple URL -

http://mysite.com/mypage.php

I know php can do the stuff very easily by fetching the content of that page and displaying it. But in my conditions, there are some problems with ajax calls and some other things.

Moreover, i prefer to use htaccess. I did some research but htaccess codes are very confusing to me.

Était-ce utile?

La solution

I took the liberty of removing the .php part from mypage.php as it has no real use, and makes the url look less pretty.

RewriteEngine On
RewriteBase /
RewriteRule ^mypage$ /index.php?this=that&this=that&whatevs=this&that=&id=5 [L,QSA]

Autres conseils

So you only want redirect http://mysite.com/index.php?this=that&this=that&whatevs=this&that=&id=5 to http://mysite.com/mypage.php?

Then use this 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]
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top