簡體   English   中英

使用 .htaccess 將根文件夾(舊 URL)的所有 .php 文件重定向到新文件夾

[英]Redirect all the .php files of root folder (old URLs) to new folder, with .htaccess

我需要使用 .htaccess 將根目錄(舊 URL)的所有.php文件重定向到已移動到新目錄(新 URL)的相同文件。

例如:

something.com/handsome.php , something.com/index.php

something.com/fold/handsome.php , something.com/fold/index.php

等等 還有:

something.com/hector/handsome.php

something.com/fold/hector/handsome.php

請幫忙,謝謝。

我認為你的正確語法是:

Redirect 301 /handsome.php http://www.something.com/fold/handsome.php
Redirect 301 /index.php http://www.something.com/fold/index.php
Redirect 301 /hector/handsome.php http://www.something.com/fold/hector/handsome.php

.htaccess文件中。 這里有更多細節: http ://www.htaccess-guide.com/redirects/。

使用 htaccess 重定向

RedirectMatch 301 something.com/handsome.php(.*) something.com/index.php$1

RedirectMatch 301 something.com/fold/handsome.php(.*) something.com/fold/index.php$1

RedirectMatch 301 something.com/hector/handsome.php(.*) something.com/fold/hector/handsome.php$1

您可以使用 htaccess 工具重定向http://www.webconfs.com/htaccess-redirect-generator.php

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM