remove everything but domain name from url

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 ^(.*)$$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: 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.


Assuming Apache:

RewriteEngine On
RewriteRule ^(.*)$ [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}   !
RewriteRule ^(.*)$$1 [L,R=permanent] 

Source : Link , Question Author : manou , Answer Author : Halfgaar

Leave a Comment