Configuration to change the landing page on AEM Dispatcher - configuration

Is there any configuration we need to provide on AEM dispatcher settings for redirecting the domain to landing page?
For example,
user enters mydomain.com, the page should redirect to www.mydomain.com/index.jsp

Redirects cannot be done within dispatcher (except directing to 404 via filters).
To do that you have to use the vhosts section of httpd (per domain) and mod_rewrite plugin, best combine it with properly done http mappings inside CQ

Added the following configuration in httpd.conf file for the requirement.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^/$ /index.jsp [R=301]
</IfModule>

Related

Redirect http to https google cloud load balance

I have created https load balance and added ssl certificate. site working with https:// but its not working http:// and getting 404 error
Added Headername as X-Forwarded-Proto and avlue as https in load balace header request
Added in .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
is there any to redirect http to https to avoid 404 error?
At this time, there is no way to directly configure the GCP Load Balancer to redirect traffic from HTTP to HTTPS; however, there is a workaround to do this. Using Nginx, you can add the following string within the nginx configuration file:
if ($http_x_forwarded_proto = "http") {
return 301 https://$host$request_uri;
}
If you are using Apache, then you will have to do the following if you want to redirect the traffic using the .htaccess file:
Run either "sudo a2enmod rewrite" or "LoadModule rewrite_module modules/mod_rewrite.so" depending on the Linux OS you are running. This will enable
Edit or create the .htaccess file in the domain root directory with the following:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
You can find more details on the following link here.
There is also an internal request to have this feature added within GCP HTTP/HTTPS Load Balancers. I cannot provide an ETA on if/when it will be applied; however, you can follow the Public Issue Tracker (PIT) on the progress of the request.

Redirecting nonexistent index.html to home page in Wordpress is causing too many redirects in browser

I recently changed my website from static html to Wordpress, and in doing so I've been redirecting all of my former and nonexistent pages with my .htaccess file whenever Google shows me a crawl error. I've been successful in redirecting all crawl errors until today. My old index.html is throwing a crawl error and when I use:
Redirect 301 /index.html http://www.example.com
... I get this from my browser:
Too many redirects occurred trying to open www.example.com. This might occur if you open a page that is redirected to open another page which then is redirected to open the original page.*
I have since removed the above redirect from my .htaccess file and will just live with the crawl error if I can't get this resolved. But I'm thinking somebody knows how to solve this and if so, I'd really appreciate it if you'd let me know how.
You could experience this redirect loop if your DirectoryIndex is set to index.html (as the first option), which is likely to be the default setting on your server.
Basically, when you access a directory, eg. http://example.com/ (the root directory) then the DirectoryIndex directive tells the server which file to serve (via an internal rewrite). eg. http://example.com/index.html. This then seeds the redirect loop.
Since you are using WordPress, you could change this in .htaccess to favour index.php instead. For example, at the top of your .htaccess file:
DirectoryIndex index.php index.html
However, you could also solve this by using mod_rewrite (which is probably preferable). In fact, since WordPress already uses mod_rewrite (eg. RewriteRule directive) then you should also be using mod_rewrite for your redirects, not mod_alias (eg. Redirect directive). You should not mix redirects from both modules in .htaccess since you can easily get conflicts. Different modules execute at different times, regardless of their order in .htaccess.
By using mod_rewrite you can avoid a redirect loop by checking against THE_REQUEST. For example:
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.html [NC]
RewriteRule ^index\.html$ / [R=301,L]

Yii2 Advanced showing blank page

I am new in yii2, When I extract yii2 advanced content from an archive with "basic application template", "Yii 2 with advanced application template" and when I upload on server, it's showing blank page.
I checked yii2 basic it's working fine but only in case of advance template getting blank page.
The advanced template url is like: ../advanced/frontend/web/index.php?r=site
But getting Error: No input file specified.
on Apache Server, getting this error:
Not Found The requested URL advanced/backend/web/index.php was not found on this server.
I tried installing from composer as well as from an archive but getting same and no index file exists inside backend/web/ and frontend/web/.
Edit:
As Jichao suggested, I tried making subdomain which points to the advanced/backend/web, But still the problem is same.
Scrrenshot:
Add .htaccess file into the root directory of your project. You should do it manually after yii2 installation. Simple example of the .htaccess file:
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ frontend/web/$1 [L]
</IfModule>
# Deny accessing below extensions
<Files ~ "(.json|.lock|.git)">
Order allow,deny
Deny from all
</Files>
# Deny accessing dot files
RewriteRule (^\.|/\.) - [F]

301 redirect for html files in one directory only to Custom Post Type in Wordpress

I am struggling to get my head around an htaccess rule to redirect requests for an html file to go to a custom post. I have looked on here and in other places and nearly got there.
I want to redirect ONLY mydomain.com/profiles/.html to mydomain.com/name_profile/
So mydomain.com/profiles/smith.html to mydomain.com/name_profiles/smith. There are some 900 html files to be redirected and they are all contained in this directory. Other html files in the domain I need to leave correctly associated.
I currently have
RedirectMatch 301 ^/([^/]+)/([^/.]+)\.html$ /$1/$2/
RedirectMatch 301 ^/([^/]+)/([^/]+)/([^/.]+)\.html$ /$1/$2/$3/
But this redirects all html pages not just the ones in the profiles directory.
I am new at htaccess and have found several tutorials but none at a level I can understand, so any help is most welcome.
Place this rule just below RewriteEngine On line:
RewriteRule ^profiles/([^.]+)\.html$ /name_profiles/$1 [L,NC,R=301]
Use this rule:
RewriteEngine On
RewriteRule ^profiles/([^.]+)\.html/? name_profiles/$1 [DPI,L,R]
Or better, remove your RewriteMatch rules and replace with this:
RewriteEngine On
RewriteRule ^([^/]+)/([^/.]+)\.html/? $1/$2 [DPI,L,R]
RewriteRule ^([^/]+)/([^/]+)/([^/.]+)\.html/? $1/$2/$3 [DPI,L,R]
This assumes that mod_rewrite is both installed and activated for htaccess files.
If you are not sure, to check if mod_rewrite is installed, look at the list of installed modules in the output of phpinfo();
By default, mod_rewrite is not enabled for htaccess files. If you are managing your own server, open httpd.conf
and make sure that the webroot directory block contains one of these lines: AllowOverride FileInfo or AllowOverride All

Server side changes in Angular html5 mode

I was wondering if any one can tell me what are the server side changes which needs to be done when you change your mode in to html5 in Angular js. because When I did tried to change the it to html 5 mode I was unable to go in to my inner html pages. in Angular API it says that suers need to do a server side changes as well.
what are the server side changes
do we need to do any other changes as well ?
You should distinguish two type of calls:
HTML calls from the browser. These should be all remapped to serve your index or whatever.
JSON API requests. These should pass through to your app server.
How to distinguish between these two types of calls, and how to remap the former, depends strongly on your setup.
If you are using nginx, for instance, a combination of checking $http_accept to be application/json (see http://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Requests and http://wiki.nginx.org/HttpCoreModule#.24http_HEADER) and rewrite (http://wiki.nginx.org/HttpRewriteModule#rewrite) you can achieve what you want.
You need to setup your server to rewrite everything to index.html per: https://github.com/angular-ui/ui-router/wiki/Frequently-Asked-Questions#how-to-configure-your-server-to-work-with-html5mode ...
<VirtualHost *:80>
ServerName my-app
DocumentRoot /path/to/app
<Directory /path/to/app>
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]
</Directory>
</VirtualHost>
My app has params passed to a controller (via ui-router) so before html5mode I would goto
www.blah.com/angapp/#/myUIrouterController?param_x=1&param_y=2
Guessing browsers know that /#/ folder path part should serve index.html.
Now that # would be gone with html5mode, the server by default doesn't know to serve the index.html for that folder since the url will just be:
www.blah.com/angapp/myUIrouterController?param_x=1&param_y=2
myUIRouterController isn't a real file so the server would just serve a 404, Hence why I think the rewrites are needed so it knows to send everything to index.html (so above in combo with the <base> tag should work... note: requireBase is optional but heard it helps older browsers like IE9 maybe).