I post this topic here, because I believe my problem can be solved somehow using .htaccess. At the moment I have a static web site. I use PHP for some simple layout and advertisements inclusions, nothing fancy. The articles are structured: main page: /index.php main article on some subject: /subject/index.php other articles on the same subject: /subject/article.php . I want to migrate this site to WordPress, which is at the moment installed in /wordpress/ directory but eventually will work on the / location. All the articles posted on WP will have permalinks like /article-title/ . I want to redirect all old articles to their new location. As far as I know, I have two ways of doing so: * include in article's PHP files code like the following: header("HTTP/1.1 301 Moved Permanently"); header("Location: http://server.com/article-title/"); header("Connection: close"); Code (markup): * use .htaccess with something like: RewriteRule /subject/article.php /article-title/ [R=301] Code (markup): What doesn't work? I have an article under /subject/index.php (main article on this subject) to be moved to /subject/ (the permalink of this article posted under WordPress). When I leave the directory and file structure, the old article is being shown. When I remove/rename that index.php, I get 403 forbidden error. When I remove/rename the entire directory, the new article is being shown. When I remove the directory, the header redirection won't work, 'cause the old URLs won't be valid and there'll be no PHP file under inputted URL. Redirection in .htaccess doesn't work. The URL stays in the address bar in my browser, WordPress says that he couldn't find the file and displays the 404. How can I solve my problem?
You want to redirect /subject/* and keep whatever's after subject and apply that to after article title...
I am prepared to write in htaccess separate redirect rules for every single article file. The new article permalinks will not the same as the old PHP file names. For example: /subject/something.php will probably become /subject-something-else/ .