301 Redirect with Glassfish - glassfish

I'm looking for a way to do a 301 redirect on Glassfish, similar to what you could do with a .htaccess file on Apache by writing something like this:
redirect 301 /old/old.htm http://www.mydomain.com/new.htm

You must add a property "redirect_n" in the virtual host.
For example:
Name: redirect_1
Value: from=/old/old.htm url-prefix=http://www.mydomain.com/new.htm
See: http://docs.oracle.com/cd/E19776-01/820-4496/ggjaa/index.html

Related

Redirect one path to another while preserving the URL before the matching criteria

I'm trying to redirect some path to another using .htaccess:
RedirectMatch 301 /de/path(.*) /path$1
What i really want to is to get rid of the "/de/" part (only when there is also /path following it) and redirect to /path. The rule above is working, however it redirects to the root of the domain.
How can i preserve the URL that is before /de/path and use it when redirecting to /path, i.e. :
http://example.com/some/otherdirectory/de/path to redirect to http://example.com/some/otherdirectory/path?
This is as simple as:
RedirectMatch 301 (.*)/de/path $1/path
If there is a need to also match what is after /de/path and append it to the new path:
RedirectMatch 301 (.*)/de/path(.*) $1/path$2

Redirect URL with Apache 2.4

I have a full working site built with Drupal 8. I already managed to use Apache in order to redirect some pages from an old domain to the new one, but now I have to set up a rule to redirect the same page from two URLs. Basically I would like to redirect from https://example.com/course/name-course=?True to
https://example.com/course/name-course.
I already tried to use the RedirectMatch as
RedirectMatch 301 "/(.*)/(.*)?=True" "https://example.com/$1/$2"
But I can't get where I want.

Apache - Redirecting from one URL to another with a new domain

I'd like to redirect a list of URLs to another list in a new domain, like this:
myoldsite.com/page1 => mynewsite.com/the-new-page-1
The base of my .htaccess file is likek this
Redirect 301 /v2/test https://newdomain.com/foo
Redirect 301 /v2/hello https://newdomain.com/bar
But when I access http://myoldsite.com/v2/test I don't get redirected to https://newdomain.com/foo. FYI the source site has a .htaccess on /v2 folder.
If your .htaccess file is inside the v2 folder already, then you don't need the /v2/ part and the redirects should be something like this:
Redirect 301 test https://newdomain.com/foo
Redirect 301 hello https://newdomain.com/bar
if the .htaccess file is in the folder ./v2/ you should omit "/v2" from your rewrite rule
or you move the rules to a .htaccess file in the document root

Redirect everything but 1 URL and it's sub URL's

I'm trying to redirect everything on a website but 1 Joomla URL (and URLS containing this keyword). Example:
Should redirect everything from www.mydomain.com to www.mynewdomain.com but this:
www.mydomain.com/home/index.php/quality/*
I tried something like this:
RedirectMatch 302 /home/index.php/(?!quality) http://www.mynewdomain.com
But It won't redirect / or /home. Also, I tried the following but won't work:
RedirectMatch 302 (?!quality) http://www.mynewdomain.com
Is there a way to archive this?
Try :
RedirectMatch 302 ^/((?!home/index\.php/quality/.*).+)$ http://www.mynewdomain.com/$1

apache2 - RewriteRule just change the name

I have a folder with content in it. URL to it: http://www.example.com/something/
Is it possible now to rewrite the URL to this: http://www.example.com/learning/?
If yes, how?
Note: Folder something has some subfolders and a lot of HTML and PHP Files, including CSS and JS stuff.
Second note:: I can just edit my httpd.conf
Edit:
I'm using apache2 and jboss. apache2 just for the proxy and rewrite module. So my jboss application can be reached at this location: http://www.example.com:1231/something/.
I just defined that the jboss application ca be reached under port 80 at this url http://www.example.com/something/.
Now i wanna do the redirect like above.
This should work:
RewriteEngine On
RewriteRule ^/something(.*) http://www.example.com:1234/learning$1 [P]