I have a webpage http://example.com. Using the htaccess file I'm redirecting users to the page https://other_domain.com:8081 if they type http://example.com/page in their browser. That works well but the problem is that when redirected, https://other_domain.com:8081 appears in the address bar of the browser. I have added the the following to the top of the htaccess file of the http://example.com webpage but still https://other_domain.com:8081 is shown as the address after redirection:
RewriteEngine On
RewriteRule ^page(.*)$ https://other_domain.com:8081$1 [L,P]
Redirect /page https://other_domain.com:8081
How can this be resolved so that http://example.com/page is shown in the address bar instead of https://other_domain.com:8081?
Related
I'm trying to passthrough (not redirect!) an empty old page to its new location using an htaccess RewriteRule.
I essentially want the user to browse to mysite.com/page-old and to see that url in their browser but be delivered the content from mysite.com/page-new. The user should not be aware that the location changed.
RewriteEngine On
RewriteRule ^page-old/?$ /page-new [PT]
The actual result is that they are redirected to page-new instead.
I found the below on apache.org which seems to validate my code some, but this is giving me a 404 error.
Description:
Assume we have recently renamed the page foo.html to bar.html and now want to provide the old URL for backward compatibility. However, we want that users of the old URL even not recognize that the pages was renamed - that is, we don't want the address to change in their browser
https://httpd.apache.org/docs/trunk/rewrite/remapping.html
RewriteRule "^/foo\.html$" "/bar.html" [PT]
RewriteEngine On
RewriteRule ^example/my-stuff/$ /example/home/ [L,R=301]
check this answer as well
How to redirect a specific page using htaccess
Adding this to my .htaccess file works to shorten the URL and get rid of the .shtml bit.
RewriteEngine On
RewriteRule about about.shtml
But, the original address http://xxx/about.shtml also still exists. I don't want Google or anyone to see that one, so I tried redirecting it to the rewritten URL:
Redirect 301 /about.shtml /about
This gives an error on Firefox that it's not working and on Google that it is being redirected too many times. Maybe it's going in some sort of a loop.
I don't want the original file to show up anywhere in the web address (with the.shtml ending), so not sure what else besides a redirect to do.
Thanks!
I've moved my site from floriskleijne.nl to floriskleijne.com, and now want any visitor to any subdomain or subdirectory of .nl to be redirected to the .com equivalent of the URL. The challenge is in the subdomains: I have a number of those, and I want them to all be redirected to the equivalent subdomain on the new domain.
So for instance,
en2nl.floriskleijne.nl/ should redirect to en2nl.floriskleijne.com/
www.floriskleijne.nl/about/the-author/ should redirect to http://www.floriskleijne.nl/about/the-author/
floriskleijne.nl/about/the-author/ should also redirect to www.floriskleijne.nl/about/the-author/
I found the solution in this thread, but this does not seem to work for me:
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.+)\.floriskleijne\.nl$
RewriteRule (.*) http://%1.floriskleijne.com/$1 [R=301,QSA,L]
There are two problems with this approach:
It doesn't work on my site: a subdomain call to the .nl domain gives me an "Apache is working normally" page at the URL I enter, with apparently no redirection at all. And a subdomain call with subdirectories and/or files gives me a 404 error.
Though this htaccess does the job of redirecting to .com, it seems to me that it ignores the no-subdomain version http://floriskleijne.nl. And indeed,iIf at all possible, I would want that to be redirected the same way (identical path). Oddly enough, floriskleijne.nl/whatever.subdir does get redirected properly.
I've checked the DNS, and I have an A record for both floriskleijne.nl and *.floriskleijne.nl, both pointing to the same IP.
I finally found a way to remove get parameters from my urls
i had url like
/s.com/file.php?name=somthing
with this code i changed them to s.com/file/somthing
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^file/(.*?)$ http://s.com/file.php?name=$1
so far everything is ok
in my local host when i click on a url like s.com/file/somthing it goes exactly to the url
but in my server it redirects to old url and shows old url
i dont want to display my old url
can someone help?
http redirects are always external => visible in the browser. Try that:
RewriteRule ^file/(.*?)$ /file.php?name=$1
I wanted a htaccess file which would set the Default page for a directory and also display the file name in the address bar.
For example:
In general, if index.html is the Index file, then typing the address http://www.example.com/ would be internally loading http://www.example.com/index.html but by default the /index.html is not displayed in the address bar. How can we display it.
Like if user enters http://www.example.com then the address should change to http://www.example.com/index.html
Please Help
Thanks
Redirect from www.example.com to www.example.com/index.html, using mod_rewrite.