What’s the error in my HTACCESS

index page and profile page show 404 after htaccess redirection
I transfered from bogger to wp..

redirected all links from year/month/postname.html to postname/ using these lines:

# WPhtc: Begin Custom htaccess
RewriteEngine On
RewriteBase /
  RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([^/]+).html$ /$3

then redirected all previous postname,html to postname/ using this line

RedirectMatch 301 ^/([^/]+).html$ /$1

I used these lines to redirect the mobile strings:

RewriteCond %{QUERY_STRING} ^m=[01]$
    RewriteRule (.*) /$1? [R=301,L]

the final format is:

# WPhtc: Begin Custom htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^m=[01]$
RewriteRule (.*) /$1? [R=301,L]
RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/([^/]+).html$ /$3
RedirectMatch 301 ^/([^/]+).html$ /$1

Then Ihave got, 404 error when opening pages like:
index.html
profile.php
etc

please help me identify the cause>

Answer

Use

RewriteRule ^(.*)$

instead of

RewriteRule ^

For detailed explanation of rewrite flags i have shared the link below.

https://httpd.apache.org/docs/current/rewrite/flags.html

Attribution
Source : Link , Question Author : Ben Johnathan , Answer Author : imvikasmunjal

Leave a Comment