-2

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

http://example.com

at the time there are request like

http://example.com?target=dirigido
http://example.com/a-quien-va-dirigido/
http://www.example.com/a-quien-va-dirigido/
...

behind.

Anybody could help?

EDIT

The following rule

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

seems to lose the ?target=dirigido request.

EDIT2

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

?target=<content>

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:

http://inside.amimusa.org/el-equipo

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

http://inside.amimusa.org/programa-integrativo-para-directivos/

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.

4
  • 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. Sep 20, 2015 at 11:01
  • I'll clarify the scenario by editing the question. Thanks
    – manou
    Sep 20, 2015 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, 2015 at 12:42
  • I've changed everything to one request by click. Thanks.
    – manou
    Sep 21, 2015 at 19:04

1 Answer 1

0

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] 
2
  • I lose the request, it keeps requesting index.php without the target.
    – manou
    Sep 20, 2015 at 10:48
  • That's exactly what you asked for. I'l update my answer.
    – Halfgaar
    Sep 20, 2015 at 10:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .