Tag: mod-rewrite

htaccess domain redirection www to non-www and the other way around code examples

The search ranking of your domain can go down If your website is accessible with and without www as both URLs with same contents are indexed by search engines and can cause duplicate contents issues. In this case, all you need to do is either redirect your www subdomain to non-www (naked domain) or the…
Read more

Commonly used regular expression patterns in apache RewriteRule

RewriteRule directive uses a Regular expression based pattern to match against URL path. In this post we will cover some basic and commonly used patterns that are most often used in RewriteRule. RewriteRule basic regex (.*) Catch-all and save (zero or more characters) (.+) Catch-all and save (one or more characters) ([a-zA-Z0-9]+) Catch-all alpha numbric…
Read more

How to redirect non-logged in users using RewriteRule in htaccess

Redirect non-logged in users using htaccess With apache mod-rewrite it is quite possible to manipulate http cookies. The cookie you set using php or RewriteRule can easily be accessed using RewriteCond directive. If you need to redirect your non-logged in users of your website to a diffrent page using RewriteRule you need to check the…
Read more

Diffrence between URL rewriting and URL redirection htaccess topic

URL rewriting and URL redirection are two different terms used to map a URL from one location to the other. These two terms often confuse new users especially when they refer to URL related queries. Some users even intermix the URL rewriting logic with URL redirection like they are talking about a particular thing with…
Read more

How to set cookies using RewriteRule in htaccess or server.config file?

Hello! In this post I will show you how we set an http cookie using a RewriteRule directive in an htaccess or server.config file. I saw many unanswered and confusing posts on StackOverflow and on other sites so I thought It would be worth writing a post that can help peope who are searching the…
Read more