I am looking if the is an easy way to keep the webpage always with the URL like:


at the time there are request like



Anybody could help?


The following rule

RewriteRule ^(.*)$ http://example.com/$1 [L,R=permanent]

seems to lose the ?target=dirigido request.


The case is the site is a single-page-application in which I load the needed html file by a a jquery load function. They recently asked me to add a carrousel with a link to the different parts of the site, so I added a request param


and I load the correspondant content.

I added some rules to make beutify urls

static resources not found when mod_rewrite

But when the user goes to:


firstable it's fine, but since the page it's a single-page application, when he/she navigates throght the menu, he/she is really going to, let's say


but in the address bar it keeps: http://inside.amimusa.org/el-equipo what is awful.

So I was thinking to make all the site works hidden everything under the domain, but the request have still to work.

  • No. The URL has to reflect the page that has been loaded. Otherwise how is the web server going to know what to serve? It will just serve the default page every time. I really don't know what you're trying to get at here. There is one way to do this, which would be a single page application all done in javascript, but even they usually use hashed URLs. – Mark Henderson Sep 20 '15 at 11:01
  • I'll clarify the scenario by editing the question. Thanks – manou Sep 20 '15 at 11:07
  • If your application relies upon the URL or a GET request to function properly, then it can't be made "beautiful". If it relied upon session cookies or a POST request, you could have your way. – zagrimsan Sep 21 '15 at 12:42
  • I've changed everything to one request by click. Thanks. – manou Sep 21 '15 at 19:04

Assuming Apache:

RewriteEngine On
RewriteRule ^(.*)$ http://example.com [L,R=permanent]

The initial match (^.*$) can be all sorts of things. I chose one that does give you access over the request URI via $1, should it be necessary.

If you simply want to make sure everybody uses the same domain and rewrite all to one, use:

RewriteEngine ON
RewriteCond %{HTTP_HOST}   !=domain.com
RewriteRule ^(.*)$         http://domain.com$1 [L,R=permanent] 
  • I lose the request, it keeps requesting index.php without the target. – manou Sep 20 '15 at 10:48
  • That's exactly what you asked for. I'l update my answer. – Halfgaar Sep 20 '15 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.