: Code for redirecting an HTML page without an extension using an .htaccess file results in a 404 error I'm trying to redirect an HTML page to a WordPress page which has no extension. The result
I'm trying to redirect an HTML page to a WordPress page which has no extension. The result of redirecting example.com/fa/home.html to example.com/fa/ 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 example.com/en/home.html 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} ^mscaspian.com$
RewriteRule (.*) www.mscaspian.com/ [R=301,L]
RewriteCond %{HTTP_REFERER} !^http://mscaspian.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://mscaspian.com$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mscaspian.com/.*$ [NC]
RewriteCond %{HTTP_REFERER} !^http://www.mscaspian.com$ [NC]
RewriteRule .*.(jpg|jpeg|gif|png|bmp)$ www.mscaspian.com [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]
More posts by @Carla537
1 Comments
Sorted by latest first Latest Oldest Best
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 www.mscaspian.com/fa
Update
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 www.mscaspian.com/fa/about Redirect 301 ^/contact.html www.mscaspian.com/fa/contact
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.