Suraj
Suraj

Reputation: 586

301 redirects rule redirect to wrong URL

When I open my website http://www.codersvolt.com, It redirects to http://www.codersvolt.com/index/ instead of http://www.codersvolt.com/index.php and It should show only http://www.codersvolt.com URL.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
RedirectMatch 301 (.*)\.html$ http://www.codersvolt.com$1/

I am redirecting pages with .html extension to pages without .html extension, Which works fine, but causing above home page issue.

Upvotes: 1

Views: 81

Answers (1)

Amit Verma
Amit Verma

Reputation: 41219

Try this :

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^$ index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME}/index.html !-f
RewriteCond %{REQUEST_FILENAME}/index.php !-f
RewriteRule . index.php [L]
</IfModule>
RedirectMatch 301 (.*)\.html$ /$1/

Upvotes: 1

Related Questions