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

htaccess clean url php

htaccess clean url php

htaccess clean url php htaccess is the page url redirect and custom url is secure in web pages and passing data another page. follow us.

htaccess clean url php
htaccess clean url php

Redirect a dynamic redirect page

RewriteEngine On RewriteRule keyword/(.*).html keyword.php?page=$1

Page Redirect


Common variable sets

[A-Z] The variable can have uppercase letters
[a-z] The variable can have lowercase letters
[0-9] The variable can have numbers
([a-zA-Z0-9]+) The variable can have any of the above, and has no limit to the number of characters.

RewriteEngine On RewriteRule ^([a-zA-Z0-9]+)$ index.php?page=$1 RewriteRule ^([a-zA-Z0-9]+)/$ index.php?page=$1

How to Remove File Extention from Urls




Remove File Extention from Urls
Remove File Extention from Urls



It's very simple way site running page url modify .htaccess file.

 http://example.com/home.php be able to load at http://example.com/home

url pass multiple variables on .htaccess

 In this post I want to explain about URLs rewriting techniques using .htaccess file. Friendly URLs looks neat on the browser address bar.



RewriteRule extraurl/(.*).html currentsite.php?id=$1 [L,QSA]

RewriteRule ^extraurl/(.*).html subayurveda.php?aid=$1 [L,QSA]

url pass multiple variable
 url pass multiple variables on .htaccess


RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ index.php?keys=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ index.php?keys=$1


<?php

$keys=$_GET['keys'];

if($keys=='home')
{
include('home.php'); // Home page
}
else if($keys=='login')
{
include('login.php'); // Login page
else if($keys=='terms')
{
include('terms.php'); // Terms page
}
else 
{
include('users.php'); // Users Gateway
}
?>

Multipul Value:

htaccess code:

RewriteRule ^([\da-z]+)/([\da-z]+)/(\d+)/?$ index.php?category=$2&language=$1&id=$3 [L,QSA,NC]
RewriteRule ^([\da-z]+)/([\da-z]+)/?$ index.php?category=$2&language=$1 [L,QSA,NC]

php code:

print($_REQUEST);
exit;

output:

category = Value and Language = Value and id






USING .HTACCESS FILES

USING .HTACCESS FILES

INTRODUCTION

The .htaccess file is a powerful tool for modifying your Apache configuration on a per-domain and even a per-directory level. Many content management systems rely on .htaccess files for configuring your site. You can also create your own .htaccess file manually.

CREATING THE .HTACCESS FILE

Your .htaccess file needs to be a plain text file. This means you need to make it in a text editing program capable of producing plain text files.
  • On a Windows machine, you can use Notepad, which is one of your built-in accessories.
  • On a Mac, you can use TextEdit. You must first open the TextEdit "Preferences" menu and, in the "New Document" section, select "Plain text." Then, you can start a new document in TextEdit for your .htaccess file.
When you save your document, make sure you name it htaccess.txt, or something similar. If you save it as .htaccess, your computer will hide the file. This is because files that start with "." are considered to be system files.
htaccess set expiry of js

htaccess set expiry of js

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 7 days"
ExpiresByType image/jpeg "access 7 days"
ExpiresByType image/gif "access 7 days"
ExpiresByType image/png "access 7 days"
ExpiresByType text/css "access 7 days"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 2 days"
</IfModule>


Set Cookie using htaccess

Set Cookie using htaccess

Header set Set-Cookie "language=%{lang}e; path=/;" env=lang

Set Cookie based on Request. This code sends the Set-Cookie header to create a cookie on the client with the value of a matching item in 2nd parentheses.

RewriteEngine On
RewriteBase /

RewriteRule ^(.*)(de|es|fr|it|ja|ru|en)/$ - [co=lang:$2:.yourserver.com:7200:/]