是否有更改网站URL路径的功能?

时间:2020-01-02 09:01:10

标签: apache http url-rewriting

我想从http://localhost/en-in/pan更改网站的路径 到http://localhost/en-in/individual/pan

不创建个人文件夹。

请告诉我是否有东西。

以下是.htaccess文件

RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]

RewriteCond %{THE_REQUEST} ^.*/index\.php 
RewriteRule ^(.*)index.php$ /$1 [R=301,L] 
RewriteRule ^(.*)index$ /$1 [R=301,L] 

RewriteEngine On example.com

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



ErrorDocument 404 https://www.example.com/404
ErrorDocument 500 https://www.example.com/404
# or map them to one error document:
# ErrorDocument 404 /pages/errors/error_redirect.php

RewriteEngine On
RewriteBase /en-us

RewriteCond %{REQUEST_URI} ^/404/$
RewriteRule ^(.*)$ /pages/errors/404.php [L]

# or map them to one error document:
#RewriteCond %{REQUEST_URI} ^/404/$ 

2 个答案:

答案 0 :(得分:0)

在基本目录(public_html或www)下创建一个.htaccess文件,并将其内容放入

RewriteEngine On #remove this line if it doesn't work
RewriteRule en-in/individual/pan(/?)$ en-in/pan [QSA,L]

然后,您可以将流量从活动链接重定向到新链接

答案 1 :(得分:-1)

这取决于您正在运行的服务器。 在apache上,这可以通过在网站的根目录上创建.htaccess文件并在其中添加Redirect命令来实现:

Redirect /en-in/pan /en-in/individual/pan