URL rewrite to add a directory at start of url

前端 未结 3 1325
轮回少年
轮回少年 2021-01-05 12:22

On my website, all images/stylesheets are in the /CMS/... directory. Recently, our website shifted to new server at a temporary url where they referenced like /newdirecto

3条回答
  •  粉色の甜心
    2021-01-05 13:02

    I'd suggest using mod_rewrite, which most apache/linux servers have. Create a file called .htaccess in the docroot of your site with the contents:

    
    RewriteEngine On
    RewriteBase /
    RewriteRule ^/CMS/(.*)$      /newdirectory/CMS/$1    [QSA]
    
    

    This method will make it transparent to the end user and no impact on current pagerank, SEO, etc value and all inbound links will be maintained.

提交回复
热议问题