I own an Angular app and an Apache server.
I set <meta name="fragment" content="!" /> on the <head> part and $locationProvider.html5Mode(true);
In my .htaccess file on the Apache server, I added this part:
<IfModule mod_headers.c>
RequestHeader set X-Prerender-Token "My_Token"
</IfModule>
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
# Don't rewrite files or directories
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
<IfModule mod_proxy_http.c>
RewriteCond %{HTTP_USER_AGENT} baiduspider|facebookexternalhit|twitterbot|rogerbot|linkedinbot|embedly|quora\ link\ preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator [NC,OR]
RewriteCond %{QUERY_STRING} _escaped_fragment_
# Only proxy the request to Prerender if it's a request for HTML
RewriteRule ^(?!.*?(\.js|\.css|\.xml|\.less|\.png|\.jpg|\.jpeg|\.gif|\.pdf|\.doc|\.txt|\.ico|\.rss|\.zip|\.mp3|\.rar|\.exe|\.wmv|\.doc|\.avi|\.ppt|\.mpg|\.mpeg|\.tif|\.wav|\.mov|\.psd|\.ai|\.xls|\.mp4|\.m4a|\.swf|\.dat|\.dmg|\.iso|\.flv|\.m4v|\.torrent|\.ttf|\.woff))(.*) http://service.prerender.io/http://example.com/$2 [P,L]
</IfModule>
# Rewrite everything else to index.html to allow html5 state links
RewriteRule ^ index.html [L]
</IfModule>
However, when I run the following command:
curl http://example.com?_escaped_fragment_=
I don't get the prerendered file.
Sounds that Prerender's service is not triggered at all.
Did I miss some configuration?
You might be serving your index from here:
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^ - [L]
Can you try moving the prerender config higher than that section?
Related
I have done a migration for IPB4 to Xenforo 1, and then to Xenforo 2.
There is a script to redirect the old urls to the new: https://xenforo.com/community/resources/redirection-scripts-for-invision-forums-3-x.5948/
Are two files and this htaccess... I have done a lot of changes and nothing, no redirection for the old urls.
Example of old url: http://www.foroiphone.com/foros/tema/119668-iphone-7-7-plus-movistar-post-oficial/ that goes to can't find the page
New XF2 Url: http://www.foroiphone.com/threads/iphone-7-7-plus-movistar-post-oficial.119668/
Here is:
# Mod_security can interfere with uploading of content such as attachments. If you
# cannot attach files, remove the "#" from the lines below.
#<IfModule mod_security.c>
# SecFilterEngine Off
# SecFilterScanPOST Off
#</IfModule>
ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 500 default
<IfModule mod_rewrite.c>
RewriteEngine On
# If you are having problems with the rewrite rules, remove the "#" from the
# line that begins "RewriteBase" below. You will also have to change the path
# of the rewrite to reflect the path to your XenForo installation.
#RewriteBase /ip.board
# This line may be needed to enable WebDAV editing with PHP as a CGI.
#RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# IPS Rewrite Rules
RewriteCond %{REQUEST_URI} /(topic|forum|user)/ [OR]
RewriteCond %{QUERY_STRING} (^|&)show(topic|forum|user)= [OR]
RewriteCond %{QUERY_STRING} ^/(topic|forum|user)/ [OR]
RewriteCond %{PATH_INFO} ^/(topic|forum|user)/
RewriteRule ^.*$ ips2xf.php [NC,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^(data|js|styles|install) - [NC,L]
RewriteRule ^.*$ index.php [NC,L]
</IfModule>
I am using laravel 5.4 default authentication system and it is working fine in localhost but when i upload my project to server, it is breaking. when i fill mail and password, it return back me 404 file not found error.
My site url is http://www.happycoder.me/imsRever2.0
You need to configure the .htaccess file as follows:
RewriteEngine On
RewriteCond %{REQUEST_URI} !^imsRever2.0
RewriteRule ^(.*)$ imsRever2.0/$1 [L]
Otherwise, the main web server will not the routing, vs laravel causing the 404 error when the file isn't found.
My htaccess file is below what things i need to change
Options -MultiViews
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
so basically I've this htaccess file
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
#RewriteRule ^(.*) /index.html [NC,L]
RewriteRule ^ index.html [L]
</IfModule>
but old website has all the .html url's like www.mysite.com/contact.html
thing is it's first page in a lot of google searches and i don't want to loose all that indexed pages, so i what i want is to get that and remove the .html
also, i've custom url's like www.mysite.com/product/whatever_my_name.html
same story, grab that and make it www.mysite.com/product/whatever_my_name
thanks in advance
RewriteCond %{REQUEST_URI} ^((?:/[^/]+)+).html$
RewriteRule ^ %1 [NS,L,R=301]
Testing only the client's request is important to avoid interference with serving any other html docs, e.g. your main index.html.
I want to redirect https://example.com to https://www.example.com for my website. Can you help me with the code to put it on .htaccess file. the site is in magento.
RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}/$1 [R=301,L]
Explained: If the requested host does not start with www., redirect it to start with www
Source|Reference: http://codingbasics.net/magento-htaccess-file-optimized-speed-security-seo/
The link above has a default Magento htaccess file that has been optimized for speed and SEO and has code for rewriting non-www to www, but does not have the code for rewriting HTTPS/SSL non-www to www. So I have grabbed the htaccess code section from the link/site above and made the additional edits to the code below for rewriting HTTPS/SSL non-www to www.
##### Search Engine redirects and rewrites for SEO purposes #####
<IfModule mod_rewrite.c>
# Rewrite|Redirect http to https|SSL & non-www to www
RewriteCond %{HTTPS} !=on
RewriteCond %{SERVER_PORT} ^80
RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC]
RewriteRule (.*) https://www.%{HTTP_HOST}%{REQUEST_URI} [R,L]
##### Redirect away from /index.php and /home
##### Warning: This index.php rewrite will prevent Magento
##### Connect from working. Simply comment out the
##### following two lines of code when using Connect.
##### Please note - https://www. if not using www simply use https://
RewriteCond %{THE_REQUEST} ^.*/index.php
RewriteRule ^(.*)index.php$ https://www.yourdomain.com/$1 [R=301,L]
##### Please note - https://www. if not using www simply use https://
redirect 301 /home https://www.yourdomain.com
Options +FollowSymLinks
RewriteEngine on
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{REQUEST_URI} !^/(media|skin|js)/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule .* index.php [L]
</IfModule>
For example, if I want localhost/basic.com for the front-end and localhost/basic/admin for the back-end.
I am new to the framework, however, it seems really interesting.
Please help.
I have watched tutorials and all but none seem to cover this.
You can use the following .htaccess
Options FollowSymLinks
AddDefaultCharset utf-8
<IfModule mod_rewrite.c>
RewriteEngine On
# the main rewrite rule for the frontend application
RewriteCond %{REQUEST_URI} !^/(backend/web|admin)
RewriteRule !^frontend/web /frontend/web%{REQUEST_URI} [L]
# redirect to the page without a trailing slash (uncomment if necessary)
#RewriteCond %{REQUEST_URI} ^/admin/$
#RewriteRule ^(admin)/ /$1 [L,R=301]
# the main rewrite rule for the backend application
RewriteCond %{REQUEST_URI} ^/admin
RewriteRule ^admin(.*) /backend/web/$1 [L]
# if a directory or a file of the frontend application exists, use the request directly
RewriteCond %{REQUEST_URI} ^/frontend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward the request to index.php
RewriteRule . /frontend/web/index.php [L]
# if a directory or a file of the backend application exists, use the request directly
RewriteCond %{REQUEST_URI} ^/backend/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# otherwise forward the request to index.php
RewriteRule . /backend/web/index.php [L]
RewriteCond %{REQUEST_URI} \.(htaccess|htpasswd|svn|git)
RewriteRule \.(htaccess|htpasswd|svn|git) - [F]
</IfModule>
FUll configurations can be found at: https://github.com/mickgeek/yii2-advanced-one-domain-config