We currently have domain.com/username redirected to domain.com/setsession.asp?u=username which then redirects to the app at domain.com/theapp.
This means users always see domain.com/theapp, so browsing to a page shows domain.com/theapp/somepage.asp
Looking to move this to subdomains ie
username.domain.com
(we'll get the host name and work out the user from that). How can this be set up? Should we move the app itself to say theapp.domain.com and then rewrite username.domain.com to theapp.domain.com and everything works?
If thats right, how can we do the URL rewrite (mod_rewrite via ISAPI Rewrite for IIS or URL Rewriting for IIS) so that we can still access webmail.domain.com, etc?
If you just want to move domain.com/username to username.domain.com, you can do this with mod_rewrite:
RewriteCond %{HTTP_HOST} ^([^.]+)\.domain\.com$
RewriteRule .* http://domain.com/setsession.asp?u=%1 [B,R=permanent]
Related
I am trying to do 301 redirect in my herokuapp. How can I do it. I have used <link rel="canonical" href="http://mysite.herokuapp.com">. And I have also used this tag for every page with the url of the page. Still I failed to fix 301 redirections problem in my heroku website.
With url http://mysite.herokuapp.com website is working but with url
www.http://mysite.herokuapp.com it shows
This site can’t be reached
Yoast seo shows this message
"Warning, no 301 redirects are in place to redirect traffic to your
preferred domain. Pages that load successfully both with and without
www. are treated as duplicate content! "
For this problem my website is not indexing in google, I think. How can i show my website in google search.
Note: I have submitted my website to google search console and verified it.
Please help me to solve this problem.
You will want to use something called htaccess
There should be a file in the root of your web directory called ".htaccess" If not create one.
You want a rule something like this:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.mysite.herokuapp.com [NC]
RewriteRule ^(.*)$ http://mysite.herokuapp.com/$1 [L,R=301]
This should redirect www traffic to a none www prefix
I have a website (built in ruby with .erb extensions) with mixed content (like a Wistia video) and so want to have that URL as http://domain.com.
However, when users click on "register," I want to direct them to an EV SSL-encrypted https://subdomain.domain.com/register folder.
Both of the above URLs work just fine, and the https URL displays the green EV SSL properly.
BUT, if in the low-probability event a user were to type "http://*/register" into his browser's address bar, that goes to the same /register page and allows him to register on that non-encrypted page. I really do not want that to happen.
I want to redirect anyone who tries to access the /register file via http to only the EV SSL-encrypted one, that is: https://*/register
sorry for using * wildcard, but I can only post 2 links.
I'm using Ubuntu 12.04 OS on an apache2 server and generally modify via ssh on my Mac's Terminal app.
Put this code in your DOCUMENT_ROOT/.htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} !^subdomain\. [NC]
RewriteRule ^register(/.*)?$ https://subdomain.domain.com/register$1 [L,NC,R=301]
Thanks for replying so quickly, Anu. That may have worked, but Rackspace support used a 301 redirect in a .conf file, and it definitely worked:
/etc/apache2/sites-enabled/domain.com.conf:5
==================================
redirect 301 /register https://subdomain.domain.com/register
I have provided a link from my web site in my andoird app which is:
www.mysite.com/support
And i want this link to be redirected to:
www.anothersite.com
i have already tried com_redirect and entered support as source and http://ww.anothersite.com but i dont get any redirects and i get 404 error.
I am running Joomla 3.x and i want to know how i can do this with URL rewrites and no external components.
It seems not possible to do it within the Joomla backend (i tried many combination of menu items and the redirect module).
For sure you can write your redirect directly in your .htaccess (if you are using it) like this:
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^support/?$ http://www.anothersite.com/ [R=301,NC,L] # Permanent Move
or
RewriteEngine On # Turn on the rewriting engine
RewriteRule ^support/?$ http://www.anothersite.com [R,NC,L] # Temporary Move
More info about URL rewriting and .htaccess are here: http://www.addedbytes.com/articles/for-beginners/url-rewriting-for-beginners/
My question is regarding RewriteMap on apache2: I want to apply a rewrite condition, so that all request on my proxy are proxied to an completely new domain.
Eg localhost/test or any other url should just go to www.mydomain.com:
RewriteRule / http://www.mydomain.com [P]
Works fine. If I access localhost, I still see "localhost" in my browser address line, but mydomain.com is presented. BUT if I now click on any link on this mydomain site, I will get a "Not Found" response.
The sourecode of mydomain contains eg this link:
Link
If I access the site in a normal way, this would result in: www.mydomain.com/lab/sale.php, and works fine.
If I access the site through my proxy and the rewriteRule takes place, I would after the link click be directed to: localhost/lab/sale.php, which does not exist of course.
Question: how can I a user that accesses the site through my proxy browse on the whole site as if he would really access this site?
The RewriteRule directive isn't like a ProxyPass or Redirect where they essentially link 2 nodes together and everything following it also gets proxied. The rule that you have only proxies the request URI /, not /lab/ or /etc.php or anything else. You need to create a match and pass that along as a backreference:
RewriteRule ^/?(.*)$ http://www.mydomain.com/$1 [P]
Or you can use the %{REQUEST_URI} variable:
RewriteRule ^ http://www.mydomain.com%{REQUEST_URI} [P]
My site is built in php and I have URL rewrites to make the .php links more SEO friendly:
RewriteRule ^page-one$ /pageone.php [L]
The problem with this is that someone, including Google bots, can still see pageone.php from when it was previously indexed. So I end up with two links for each page. That's bad.
How can I set this up so that I get the benefit of rewriting to page-one, while somehow making sure an external request to pageone.php is redirected to page-one?
How about redirecting page-one.php to pageone?
RewriteRule ^page-one.php$ /pageone [R=301,NC,L]