0

First of all let me say: I have almost no experience with htaccess and all code looks like gibberish to me.

I have a form that send the visitor to a page like this: mysite.com/date.php?day=2014-06-03

I want them automatically redirected to: mysite.com/2014-06-03

I currently have the following code in my htaccess, which already makes the page work, the old page just does not get redirected yet.

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* date.php/?day=$0 [PT] 

I'd be really glad if someone could take a look at this. It seems like this should be fairly easy but all the similar questions are JUST a bit different or too hard for me.

EDIT:

Changed my form using this question: Clean URLs for search query?

Community
  • 1
  • 1

1 Answers1

0

The RewriteRule directive doesn't operate on the query string. It only works with paths. You need to add a condition on the query string:

RewriteCond %{QUERY_STRING} ^day=([^&]+)
RewriteRule $/date.php^ /date.php/?day=%1 [R=301,L] 
benjamin.d
  • 2,801
  • 3
  • 23
  • 35