Forum Moderators: phranque
My old permalinks are http://www.example.com/dblog/articolo.asp?articolo={ID}
Now I want to move to Apache using a PHP platform. My new permalink will be: http://www.example.com/post/{ID}/
I tried using RedirectMatch, but it doesn't work.
I tried using rewrite:
RewriteCond %{QUERY_STRING} ^articolo=(.*)$
RewriteRule ^/(.*)$ http://www.example.com/post/$1/ [R=301,L]
It doesn't work to...
What can I do?
Thanks in advance
Your code is almost correct, but for use in .htaccess, the URL-path 'seen' by RewriteRule will not have a leading slash. So remove the leading slash from the RewriteRule pattern to start.
If you don't have any other working rules, then you will need to add
RewriteEngine on And if that still doesn't work, then add
Options +FollowSymLinks $1 refers the the value matched by the first RewriteRule pattern. %1 refers the value matched by the first RewriteCond pattern (of the last RewriteCond that matched if there are multiple RewriteConds).
You will also need to add a "?" to the substitution URL to clear the current query string.
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{QUERY_STRING} ^articolo=(.*)$
RewriteRule ^articolo\.asp$ http://www.example.com/post/%1/? [R=301,L]
Options +FollowSymLinks
RewriteEngine on
#
RewriteCond %{QUERY_STRING} ^articolo=(.*)$
RewriteRule ^dblog/articolo\.asp$ http://www.example.com/post/%1/? [R=301,L]
Jim
The problem was the /dblog/ directory. In my new blog, all files will be stored in the root (or, in any case in a none dblog directory)
I solved creating the dblog directory and storing inside a different .htaccess
The code posted in the first post was part of the main .htaccess
Using this code
#############################
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{QUERY_STRING} ^articolo=(.*)$
RewriteRule ^articolo\.asp$ http://example.com/post/%1/? [R=301,L]
###############################
In /dblog/.htaccess all works fine!
Thanks for the support and compliments for the board (since yesterday I was a great lurker ^_^ )