I have below url structure


and I want to below


but I am getting error when I am using .htaccess

Error: http://example.com/example.com (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36

My .htaccess code is below

<IfModule mod_rewrite.c> 
Options +FollowSymLinks -MultiViews

RewriteEngine On 
RewriteBase /

#removing trailing slash
#RewriteCond %{REQUEST_FILENAME} !-d 
#RewriteRule ^(.*)/$ $1 [R=301,L]

#www to non
#RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?example\.com)$ [NC]
#RewriteRule .? http://%1%{REQUEST_URI} [R=301,L]

#RewriteCond %{REQUEST_FILENAME} !-f 
#RewriteCond %{REQUEST_FILENAME} !-d 
#RewriteRule ^([^\.]+)$ $1.php [NC,L]

#index redirect 
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/ 
RewriteRule ^index\.php$ http://example.com/ [R=301,L]
#RewriteCond %{THE_REQUEST} \.php 
#RewriteRule ^(.*)\.php$ /$1/$2 [R=301,L] 

#SEO friendly Blog page URL
#RewriteRule /(.*)/$ blog.php?blogURL=$1
#RewriteRule ^([a-zA-Z0-9-/]+).php$ blog.php?blogURL=$1

# Redirect /Category.php?Category_Id=10$Category_Title=some-text
RewriteCond %{QUERY_STRING} ^blogURL=([\w-]+)$
RewriteRule ^blog\.php$ /blog/%1? [L,R=301]


What is the issue?

  • 1
    To confirm... have you already changed the URL in your application, so you are already linking to the desired URL? Are you in the process of changing your URL structure - so, the old URLs are already indexed? – MrWhite Aug 7 '18 at 14:58
  • yes, I want to change URL structure. like example.com/blog/… instead of example.com/… – Kumar Aug 8 '18 at 4:27
  • That’s not what I was asking... have you changed the URL in the application itself? Ie. Are you already linking to the desired URL in your HTML? The thing is, you don’t “change the URL structure” in .htaccess alone - a seemingly common misconception - but the directives you’ve posted perhaps suggest that this is what you are trying to do? So, we need clarification, before we can answer your question. – MrWhite Aug 8 '18 at 8:16
  • 1
    thanks for all, Yesterday I solved this issue by this code RewriteEngine On RewriteRule ^([a-zA-Z0-9_-]+)$ example.php?cat=$1 – Kumar Aug 10 '18 at 4:49