I am using AEM. I have configured some vanity URL's with redirect. Ex:
/coaties > /content/geometrixx-outdoors/women/coats/winter-coat.html
Also in the web server, I have made configuration to strip HTML extension so my web-server removes the html extension with another redirect. Now when I hit vanity URL, I will have 2 redirects
/coaties > /content/geometrixx-outdoors/women/coats/winter-coat.html [1st redirect]
/content/geometrixx-outdoors/women/coats/winter-coat.html >
/content/geometrixx-outdoors/women/coats/winter-coat [2nd redirect]
I want to avoid 2 redirects and I dont want to show HTML extension to end users.
/coaties > /content/geometrixx-outdoors/women/coats/winter-coat [only one redirect]
I spent some time on the Sling side with no luck. All I understand is, since Sling will return 403 for all URL's without extension, it always returns URLs with extension. Is this possible at dispatcher or web server side ?
If i understand, you want to strip the .html extension from all the pages of your site.
The solution of #awd will ensure that all the hrefs in your page would be transformed to uris with no extension.
If you want no extension at all in your site, you should use an internal redirect by creating map under /etc/maps, you can find the official documentation here: http://sling.apache.org/documentation/the-sling-engine/mappings-for-resource-resolution.html
Thanks everyone for contributing.
I found the following solution for the problem
I would do the following configurations for webserver
For apache, in httpd.conf
Header edit Location (.*).html$ $1
For iPlanet in obj.conf
<If $srvhdrs{'Location'} =~ "^(.*).html$">
Output fn="set-variable" $srvhdrs{'Location'}="$1"
</If>
This would make sure that html extension would be removed from location header for redirected URL's.
Related
I have a basic project running on IIS 8.5
sites
-> test.domain.com
--->virtualPath
----->index.html
On the browser when enter https://test.domain.com/virtualpath, it is return 301 (redirect) to test.domain.com/virtualpath/
I don't have any URL Rewrites in IIS configuration. Just trying to figure out why it is redirecting to test.domain.com/virtualpath/
How can avoid this 301 redirect?
The short answer is that IIS doesn't handle extensionless URLs very well. URLs are processed based on the file extension, otherwise it's presumed to be a directory you're looking to get served. The normal convention however is to omit the index.html file.
But most services like IIS take that for granted, and if nothing is specified, it will lookup if there's a /index.html.
Lets take a simple example:
google.com
In reality what's being served to you is:
google.com/index.html
Lets take your request as an example https://test.domain.com/virtualpath
test.domain.com
- virtualPath/
- index.html
As you can see, you're essentially trying to get a directory rather than a specific file. It's up to IIS to try to find and understand that you want a file instead of a directory now. That's why you're getting a 301. It's redirecting you to the /index.html file.
I have internal links like: http://example.com/payment/
If to enter this link instead http://example.com/payment I get an error 303.
How to configure .htaccess for redirect?
Add this redirect into your .htaccess file.
This allows you to redirect your entire website to any other domain
Redirect 303 / http://example.com/payment/
Redirecting a URL: Using Redirect in an .htaccess file enables you to redirect users from an old page to a new page without having to
keep the old page. For example, if you use index.html as your index
file and then later rename index.html to home.html, you could set up a
redirect to send users from index.html to home.html.
For example:
Redirect /path/to/old/file/old.html http://www.example.com/new/file/new.html
You can find more detailed examples here.
I want to print a short, easy-to-type URL on paper brochures.
So that people can type example.com/foo into their smartphone browser, and the browser will display an existing page, say http://example.com/bar/yada.php .
I see that most pages about modrewrite involve regex, but what if I only need manually defined single pages?
Should I have an actual foo directory in the web root, containing a .htaccess file?
The following did what I needed, placed in the .htaccess at webroot.
An actual foo directory need not exist.
RedirectMatch 301 "(?i)^/foo$" "/bar/yada.php"
RedirectMatch 301 "(?i)^/foo/$" "/bar/yada.php"
I just notice if we append "#anydomain.com" to any URL Chrome (and also FF) redirects user to the domains appended.
For example:
http://www.google.com#facebook.com/ - Will redirect to facebook.com
http://www.facebook.com#google.com/ - Will redirect to google.com
I would like to prevent it from my website, does anyone know anything about it?
Thanks in advance!
-B.J.
Adding more info:
If I try to add a '/' before the '#', like this:
http://www.google.com/#facebook.com/
Then Google gives me 404 page not found... But my website still redirects with the '/'
The # symbol is used as part of the URI scheme to login users to a site.
If you notice, as soon as you click it says "You are about to log in Facebook.com with the username..."
Its part of the HTTP protocol. You can't really do anything about it.
Read : http://en.wikipedia.org/wiki/URI_scheme
I fix it.
The issue was in the Apache configuration, the permanent redirect I have to redirect from HTTP to HTTPS had the wrong template, it was missing a final slash '/'.
So when accessing:
http://mydomain.com/#anotherdomain.com
it was redirecting to https://mydomain.com#anotherdomain.com without the final slash, and the browser default behaviour was to redirect to anotherdomain.com without even hitting my server.
It was only about adding the slash on the redirect clause I have.
Redirect permanent https://mydomain.com/
I have a VPS based Centos/cPanel-WHM. I wanna redirect all sites (including all pages & subdomains) on the server to one URL. How can i do this?
create .htaccess file in every website DocumentRoot dir which you want to redirect
# This allows you to redirect your entire website to any other domain
Redirect 301 / http://exampledomain-redirect.com/
At webserver layer (change the .htaccess), you could issue 301 redirects for any requests to your sites to new URL
OR
you could inject javascript (through your web layer) or your code layout framework OR manually
at the head of the page to complete a redirect.
OR
if your domains point to different hosting.. you could upate their NS to point to your new location and do 1 OR 2
.htaccess is the best way, Otherwise change the document root for each site.