How to Remove Folder Name from URL throught .htaccess

Discussion in 'PHP' started by sunilraj, Nov 22, 2010.

  1. #1
    Hello All,

    I have a dynamic site, the url structure is abc.xyz.com/State/sitemap/deep-link-page.html

    So I want to drop the "sitemap" from the Url and the url structure should be abc.xyz.com/State/deep-link-page.html

    Please suggest me the htaccess code so that it would be helpful for me.

    Thanks in Advance
     
    sunilraj, Nov 22, 2010 IP
  2. MyVodaFone

    MyVodaFone Well-Known Member

    Messages:
    1,048
    Likes Received:
    42
    Best Answers:
    10
    Trophy Points:
    195
    #2
    You could try a redirect which means you don't need to edit your files, anyone clicking State/sitemap/deep-link-page.html will go to /State/deep-link-page.html

    
    RewriteEngine on
    
    RewriteBase / 
    
    Redirect 301 /State/sitemap/deep-link-page.html State/deep-link-page.html
    
    RewriteRule ^/State/deep-link-page.html$ /State/sitemap/deep-link-page.html [L]
    
    Code (markup):
    Not tested might need tweaking...
     
    MyVodaFone, Nov 22, 2010 IP