how to use regular expressions in the middle of redirect in .htaccess

Viewed 26

Consider the snap of code in .htaccess.

AddDefaultCharset UTF-8

ErrorDocument 404 /error-404/

Redirect 301 /day /published/?duration=day
Redirect 301 /week /published/?duration=week
Redirect 301 /month /published/?duration=month
Redirect 301 /year /published/?duration=year

Redirect 301 /trending/day /trending/?duration=day
Redirect 301 /trending/week /trending/?duration=week
Redirect 301 /trending/month /trending/?duration=month
Redirect 301 /trending/year /trending/?duration=year

Redirect 301 /new/day /new/?duration=day
Redirect 301 /new/week /new/?duration=week
Redirect 301 /new/month /new/?duration=month
Redirect 301 /new/year /new/?duration=year

Options +FollowSymlinks -MultiViews
RewriteEngine on
RewriteBase /

## Set home page
RewriteRule ^/?$ index.php?con=home&task=published [L]

It is working well. The problem is when I try to use regular expression kinds of stuff, it is not working ...

UPDATE:

For example: When the user tries to browse http://example.com/month it should redirect to http://example.com/published/?duration=month.

FYI, I am going to process the entire request in index.php ...

Can you please suggest to me some examples to FIX and minimize the above code in .htaccess?

0 Answers
Related