Showing posts with label .htaccess. Show all posts
Showing posts with label .htaccess. Show all posts

Thursday, December 22, 2016

joomla 301 redirection from with index.php to without URLs

This can be done using .htaccess file. Open it and add the following code

RewriteEngine On

########## Begin - 301 Redirect

RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*(index|home)\.html?\ HTTP/
RewriteRule ^(([^/]+/)*)(index|home)\.html?$ http://www.yourdomain.com/$1 [R=301,L]

RewriteCond %{THE_REQUEST} !^POST
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.php\ HTTP/
RewriteCond %{SERVER_PORT}>s ^(443>(s)|[0-9]+>s)$
RewriteRule ^(([^/]+/)*)index\.php$ http%2://www.yourdomain.com/$1 [R=301,L]

#RedirectMatch 301 ^/index.php/(.*)$ http://www.yourdomain.com/$1

RewriteCond %{REQUEST_URI} ^/index\.php/
RewriteRule ^index.php/(.*) /$1 [R,L]

RewriteCond %{HTTP_HOST} !^(www\.yourdomain\.com)?$
RewriteRule (.*) http://www.yourdomain.com/$1 [R=301,L]
########## End - 301 Redirect


*****************************************************************
 
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ http://www.yourdomain.com [R=301,L] 
 
RewriteCond %{REQUEST_URI} ^/index\.php/
RewriteRule ^index.php/(.*) /$1 [R,L] 

Wednesday, March 30, 2016

Redirect url with dynamic server address in .htacess

To make it more dynamic lets use SERVER_NAME and REQUEST_URI instead of a static domain name. This is the way to redirect to HTTP non-www to HTTPS www htaccess.

RewriteEngine On

#we replace domain.com/$1 with %{SERVER_NAME}%{REQUEST_URI}.
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*) http://www.%{SERVER_NAME}%{REQUEST_URI} [L,R=301]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . index.php

#here we dont use www as non www was already redirected to www.
RewriteCond %{HTTPS} off
RewriteRule ^(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
 
 

Monday, April 15, 2013

Controlling access with .htaccess | On form submit to change url in php


Once you submit the button , the url  will change with your search word.  And you encode the url in java-script and add your additional parameters. 


<script>
var url_v      =   $('#searchform').attr("action");
var parameters =   $("#searchingchart").val();
parameters_v   = encodeURIComponent(parameters);
url_v          = url_v + parameters_v   ;
$('#searchform').attr("action",url_v);
</script>

 <form name="form" method="post"  action="/products/"  id="searchform">
 <input type="text"  name="search_val" id="searchingchart" value=""/>
 <input type="submit" id="submit" value="Search"/>
 </form>

In your website url with .(point), you get 404 error . On that time we control the url in .htaccess.

Paste this code in .htacess to get the url has workable.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]


Example URL:
http://www.yoursite.com/products/Max. volume