Before proceeding with the answer, if I understand correctly you want to redirect from https://halopredictions.com/blog/german-bundesliga-prepare-to-return-on-9-may
To https://halopredictions.com/blog/index.php?url=german-bundesliga-prepare-to-return-on-9-may
.
Since SEO Urls are used by the visitors, we have to convert them to actual path.
The below RewriteRule will be sufficient to achieve the above condition.
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^blog/([A-Za-z0-9-\+]+)/?$ blog/index.php?url=$1 [NC,L,QSA]
Explanation:
^blog/([A-Za-z0-9-\+]+)/?$
- This part is what you want to rewrite from. Since, your URLs will be like in the pattern https://halopredictions.com/blog/german-bundesliga-prepare-to-return-on-9-may
, we need to get the url part after blog/
.
I have used a regular expression ([A-Za-z0-9-\+]+)/?
to match the url part and it can be referrenced using $1
.
Now we have to use $1
in our new url. For that, we have written the second part of RewriteRule where you can assign the referrence.
blog/index.php?url=$1
- Now, as you would assume we are using the $1
reference after index.php?url=
, so that it will append it to the URL Query param and should lead to a valid path.
By the way, ^
this is used to indicate the start and $
for the end.