.htaccess add an extra word to add all my URLs

柔情痞子 提交于 2019-12-24 10:50:01

问题


I need to a add a extra word right after my domain name to all my website URLs.

Lets say my url is http://www.example.com/somecategory/someproduct.html, it should be http://www.example.com/logado/somecategory/someproduct.html.

Is it possible to do it with .htaccess file ?

If so what should i add to my .htaccess file ?


回答1:


You can use this code in your DOCUMENT_ROOT/.htaccess file:

RewriteEngine On
RewriteBase /

# prefix each URL by /logado/ if it is not present
RewriteCond %{THE_REQUEST} !\s/+logado/ [NC]
RewriteRule ^ logado%{REQUEST_URI} [R=302,L,NE]

# internally remove /logado/ from all URLs
RewriteRule ^logado/(.*)$ $1 [L,NC]


来源:https://stackoverflow.com/questions/29946382/htaccess-add-an-extra-word-to-add-all-my-urls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!