-1

I need to change an incoming http request

  • for www.pathfinder.com/T/client/care/login.html
  • to look like www.Theshop/care/login.html

in the "URL" line on the browser.

How can this be done with using "URL" re-write?

I've tried

RewriteEngine on
RewriteRule "^www.pathfinder.com/T/clients/care/$" "www.Theshop.com/care/"

but this doesn't seem to work.

5
  • 1
    What have you tried so far? serverfault.com/questions/650474/… seems like a good place to start Commented May 1, 2019 at 8:28
  • RewriteEngine on RewriteRule "^www.pathfinder.com/TMAS/clients/care/$" "lightwaytechnologiesapps.com/" RewriteCond "%{HTTP_HOST}" "^www\.pathfinder.com/TMAS/clients/care/$" [NC] RewriteRule "^/?(.*)" "lightwaytechnologiesapps" [L,R,NE] Commented May 1, 2019 at 8:30
  • You can (and should) edit the question directly actually. Please check my edit and maybe also make sure your rules actually match the example you've given. Commented May 1, 2019 at 10:01
  • 1
    The rewrite rules you've tried don't match your requirements. You've asked to rewrite pathfinder.com/T/... but your rules expect www.pathfinder.com/TMAS/.... They're not the same. Commented May 1, 2019 at 10:04
  • Why do you think mod_rewrite can do this? Commented May 1, 2019 at 14:03

1 Answer 1

1
RewriteEngine On  
RewriteCond %{HTTP_HOST}          ^(?:www\.)?(.+)$ [NC]
RewriteRule ^/t/client/(care/.*)$ http://www.theshop.com/$1 [NC,R,L]

This will redirect
    http://www.pathfinder.com/T/client/care/foo.html
or http://pathfinder.com/T/client/care/foo.html
to http://theshop.com/care/foo.html

using flags

If you only want to redirect the login page use

RewriteRule ^/t/client(/care/login.html)$ http://www.theshop.com$1 [NC,R,L]
6
  • thanks! I do not want to redirect to another page; i only want to change the displayed name in the browser window and stay on the same page. Commented May 1, 2019 at 13:59
  • You can only change the URL by redirecting or using javascript (window.location.href="http://www.theshop.com";) or using a <meta http-equiv="refresh" content="3; URL=http://www.theshop.com/">-tag which will also reload the page. I don't know what you mean. Commented May 1, 2019 at 14:19
  • just want to replace the displayed url(which is a long path name) with something simple that someone can remember (not short url) not a new url somewhere else. This can not be done with rewrite? Commented May 1, 2019 at 14:42
  • This is what mod_rewrite does. It changes one URL to another and the request is redirected (or proxied) to the new location. If the new URL points to the same host or not is up to you. Remove http://www.theshop.com from the rule and you'll stay on the same server. Commented May 1, 2019 at 15:04
  • ok i added that ; and when i open the old page; nothing changes. Commented May 1, 2019 at 15:23

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.