Redirect rules of htaccess

If you want to redirect to to, check below rules.

RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

~~~~~~~~~~~~~~~~~~~~~ O ~~~~~~~~~~~~~~~~~~~~~~~~~

Now if we open some folder and then we need to redirect to www check below rules

RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteRule ^(.*)$$1 [L,R=301]

For example i want to open myfolder url and i have entered

Our first url will not work in this time we need to create a new htaccess file and put into myfolder folder.

and then if you tried to open it will be redirect to

Here some example of htaccess rules

RewriteRule ^([a-zA-Z0-9]+)/?$ index.php?var1=$1 [L]
RewriteRule ^([a-zA-Z0-9]+)/([a-z]+)$ index.php?module=$1&var1=$2 [L]

RewriteRule ^([a-zA-Z0-9]+)/([A-Z0-9]+)$ index.php?var1=$1&var2=$2 [L]
RewriteRule ^([a-zA-Z0-9]+)/([A-Z0-9]+)/([a-z]+)$ index.php?var1=$1&var2=$2&var3=$3 [L]




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s