的.htaccess添加一个额外的单词添加所有我的网址我的、单词、网址、htaccess

2023-09-02 09:54:17 作者:不许凶我了啦

我需要一个右后我的域名给我所有的网站的网址添加额外的字。

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

比方说我的网址是 http://www.example.com/somecategory/someproduct.html 时,它应该是 http://www.example.com/logado/somecategory /someproduct.html 。

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

是否有可能使用.htaccess文件做呢?

Is it possible to do it with .htaccess file ?

如果这样,我应该怎么添加到我的.htaccess文件?

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

推荐答案

您可以在 DOCUMENT_ROOT /的.htaccess 文件中使用此code:

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]