Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I'm trying to redirect an HTML page to a WordPress page which has no extension. The result of redirecting to is a 404 page not found. As you can see they're both in a sub-directory.

I've tried many approaches, whether manually or through cPanel to redirect those URLs. Note that I'm using a Nginx web server.

When I try to redirect another URL like which is NOT in the /fa directory, it will successfully redirect. I have an .htaccess file in the root folder and one in the /fa directory. I deleted everything in the .htaccess file in the /fa directory and only left the default index page rule, but still no luck.

The .htaccess code in the root directory is:

RewriteEngine on
DirectoryIndex Portal.html

RewriteEngine On
RewriteCond %{HTTP_HOST} ^$
RewriteRule (.*)$1 [R=301,L]

RewriteCond %{HTTP_REFERER} !^*$      [NC]
RewriteCond %{HTTP_REFERER} !^$      [NC]
RewriteCond %{HTTP_REFERER} !^*$      [NC]
RewriteCond %{HTTP_REFERER} !^$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ [R,NC]

ErrorDocument 404 /404.html 

And the code in the /fa directory is:

 DirectoryIndex index.html index.htm index.php

 <IfModule mod_rewrite.c>
 RewriteEngine On
 RewriteBase /fa/
 RewriteRule ^index\.php$ - [L]
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule . /fa/index.php [L]
share|improve this question
You have to show your redirect code for us to help you – John Conde Jul 22 '14 at 20:32
i added them in the question. they're like the default settings. by the way, my wordpress install folder is in a sub-directory of /fa. – Saeed Jul 22 '14 at 20:41
You need a 301 Redirect, not a URL Rewrite. – eyoung100 Jul 22 '14 at 20:41
when i do the 301 Redirect in Cpanel it writes RewriteCond %{HTTP_HOST} ^mscaspian\.com$ [OR] RewriteCond %{HTTP_HOST} ^www\.mscaspian\.com$ RewriteRule ^fa\/home\.html$ "http\:\/\/www\.mscaspian\.com\/fa\/" [R=301,L] in the root htaccess – Saeed Jul 22 '14 at 20:44
You state you are using Nginx, but you are using Apache .htaccess directives - how does that work? – w3d Jul 23 '14 at 10:12

1 Answer 1

up vote 1 down vote accepted

I believe this will start you off right: I don't believe the rewrite rule is necessary, when the default page for WordPress is index.php

Options +FollowSymLinks
RewriteEngine on

Redirect 301 ^/home.html


Localizing WordPress
List of Localization Plug-Ins

I am not affiliated in any way to the list of plug-ins above, just Googled for:

localize wordpress content

Update 2
List of Common Redirects

As per your comment, you need to add a redirect rule for all pages, as a separate line, Ex:

Redirect 301 ^/about.html
Redirect 301 ^/contact.html

As I stated earlier, since the default page is index.php. and all these pages are handled by index.php, redirecting to the "Pretty URL" is perfectly legal, only if you have the rules for Pretty Permalinks Enabled, before the redirects.

share|improve this answer
i added the the code once in root htaccess and once in /fa directory's, still getting 404 error. the directory is blocked by robots.txt so you can check the live URL. – Saeed Jul 22 '14 at 20:50
Because to Apache your localized version counts as a Directory, and you only need it in the root, as people typing home.html need to go to /fa. Visitors in /fa are already in the correct place. See Edit. – eyoung100 Jul 22 '14 at 20:54
Oh yes now it's redirecting. your edited code works just fine. i have no idea what an ^ can do in there but apparently that just changed everything. Thank you! – Saeed Jul 22 '14 at 21:03
the Carat(^) is a WildCard Character. Translation: Catch all URL's that end in /home.html regardless of whats in front of home.html. Your rule was incorrectly coded because you weren't catching the localized translation language in the path. Be aware with that rule, that until you localize WordPress, all visitors, regardless of language will be redirected to the Arabic language page – eyoung100 Jul 22 '14 at 21:10
i have 2 questions. 1st. what if i wanted to use the above rule in the root htaccess instead of the one in the /fa directory. and 2nd. i almost localized wordpress for that language but wordpress is so smart that it will know which directory it is in and if the directory's name is one of language code (like fr/fa/en) it will have different response ? sorry if i ask simple questions. – Saeed Jul 22 '14 at 21:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.