i am facing xxs problem and i am using ISAPI Rewite 3. I want to detect if a querystring contains ... or redirect it to my home page.
Try using the following structure:
RewriteEngine on
RewriteBase /
RewriteCond %{QUERY_STRING} ^(.*iframe.*)$
RewriteRule .* http://www.domain.com [NC,R=301,L]
Related
I'm working for a company and just deployed a project for them, but I encountered an issue. so, when you go to the link http://domain, you can go to the page, and from there you can go to any other page (react route), but if you go directly to http://domain/some-end-point, it shows 404 not found. does anyone know how to fix it?
That happened because your server side doesn't handle redirect to index.html, You can fix it by config your back end to always redirect to html, or simply you can fix it from react-router using HashRouter instead of BrowserRouter
here is a full explanation about Server side vs client side routing
Add the following code to the public folder file name should be
_redirects
/* /index.html 200
refer image
You can fix this with .htaccess in the root folder :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>
I am working in angular project. I am using angular ui routing. link is http://keraiz.com. I need to remove # from url. so I enable html5 mode by
$locationProvider.html5Mode(true);
The I define base href by <base href = '/' />
then I write rewite rules in .htassess file -
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} !^(/index\.php|/img|/js|/css|/robots\.txt|/favicon\.ico)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./index.html [L]
Now on same tab it is working fine. but If I reload link or open line in new tab it jump on 404 page. so how can I resolve this issue. I don't want to go 404 page. like if there is request of keraiz.com/about then i want to go about page
I've got an AngularJS app running on top of CakePHP 2.6. I'd like to enable html5mode in Angular so I don't have to include a # in URLs, but doing so requires configuring some .htaccess files so that all requests hit index.html.
Not all of my web app is Angular yet, so I can't just redirect everything to index.html- instead, I'd like to set things up so that all requests to a certain subdirectory (and its subdirectories) redirect to that subdirectory's index.html.
CakePHP has a folder structure like this:
/ // Server web root directory: index.php, etc
----/app // The directory containing the actual Cake app
----/webroot // Web assets used by the Cake app
----/myapp // Where I'd like to store the index.html for my Angular app
I'd like to get this set up so that any requests to /myapp or its subdirectories get automatically redirected to /app/webroot/index.html. Does anyone have any ideas about how to go about this?
My current .htaccess files:
/:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
/app:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
/app/webroot:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/(app/webroot/)?(img|css|js|eot)/(.*)$
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
I would just create a controller in CakePHP to handle all requests for myapp and render the static HTML as a view with a custom layout (if required).
Performance will not be an issue because the route for CakePHP will only be executed once. After that the AngularJS app is running and will take over all HTML5 routing locally in the browser.
While you can achieve what you want in .htaccess it limits you to running the CakePHP application on Apache. If you want to scale later to IIS or Nginx you'll have to recreate these rewrite rules.
I've coded a brand new website as a side project and I'd like it to get indexed by Google and co.
The website has been made with AngularJS and optimised for SEO (at least, I tried to).
So far, Google has indexed each page in a terrible way:
www.mywebsite.com/#!/post/title-of-this-post/
While the page has been declared in a sitemap.xml:
<url>
<loc>http://mywebsite.com/post/title-of-this-post</loc>
<lastmod>2015-08-04T00:00:00+00:00</lastmod>
<changefreq>daily</changefreq>
</url>
The Website is using HTML5 routes to remove the #! symbols.
When I try to reach the indexed page, it goes to the home one. I need to remove the trailing slash.
So far, I've been able to create the following HtAccess file:
DirectoryIndex index.html
RewriteEngine On
RewriteBase /
# BEGIN Seo crawler
RewriteCond %{QUERY_STRING} ^_escaped_fragment_=(.*)$
RewriteRule ^$ /crawler.php$1 [QSA,L]
# END Seo crawler
# BEGIN sitemap and rss
RewriteRule ^sitemap.xml$ sitemap.php [L]
RewriteRule ^rss.xml$ rssfeed.php [L]
# END sitemap and rss
# BEGIN Remove trailing slash from URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} (.*)$
RewriteRule (.+)/$ http://%{HTTP_HOST}/$1 [R=301,L]
# END Remove trailing slash from URLs
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteRule (.*) index.html [L]
But this doesn't work.
Typing http://mywebsite.com/post/title-of-this-post/ will correctly redirect to http://mywebsite.com/post/title-of-this-post (Trailing slash is removed).
Typing www.mywebsite.com/#!/post/title-of-this-post/ will sadly redirect to www.mywebsite.com/home.
Typing www.mywebsite.com/#!/post/title-of-this-post (Without the trailing slash) will correctly redirect to http://mywebsite.com/post/title-of-this-post.
Is there a way to achieve that ?
I'm using Route UI on my AngularJS Project.
Finally, I've managed to fix it on my own:
Just add this piece of code to your AngularJS source:
app.config(function ($urlMatcherFactoryProvider) {
$urlMatcherFactoryProvider.caseInsensitive(true);
$urlMatcherFactoryProvider.strictMode(false);
});
I am working on AngularJs with HTML5 mode enabled for SEO friendly URLs, its working fine with the in app navigation but on reload.
Have written below .htaccess but still facing the same issues for nested navigation
RewriteEngine On
RewriteBase /akv/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !index
RewriteCond %{REQUEST_URI} !.*\.(css|js|html|png|jpeg|gif|)
RewriteRule (.*) index.html [L]
Its working fine for fist level navigation like base/Blog or base/Portfolio but base/Blog/MyBlogTitle/type/post/id/1
Is there is any way to fix it.
Thanks in advanced.
Problem is that you're using relative URLs in your css/image/js paths. Relative URLs are resolved as browser adds them to the current path thus giving you 404 when using pretty URLs.
To fix this problem you can add this in your page's HTML <head> section:
<base href="/kv/" />
so that every relative URL is resolved from that URL and not the current page's URL.