Richard
Richard

Reputation: 38

How to redirect with .htaccess?


I have the following htaccess code already.

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

I would like that the htaccess redirect to

oszoczki.atwebpages.com/blog

when I type only

oszoczki.atwebpages.com

Upvotes: 0

Views: 62

Answers (1)

nice_dev
nice_dev

Reputation: 17805

RewriteEngine On
RewriteRule ^$ /blog [R=301,L]
  • The ^$ in RewriteRule matches an empty URI and redirects to /blog.
  • R=301 represents a permanent direction.
  • L represents the last rule to be applied to this and ignore all others below it.

Update:

You can remove the L flag since redirection would have happened anyway as mentioned by @arkascha in the comments.

Upvotes: 2

Related Questions