.htaccess 为不同路径重写多个URL

.htaccess 为不同路径重写多个URL,.htaccess,mod-rewrite,url-rewriting,.htaccess,Mod Rewrite,Url Rewriting,如何实现同时重写多个URL。我知道我可以一次重写一个url,但不确定如果多个url 假设我有这些文件并想重新写入它们: https://www.mydomain.com/log/member/1 https://www.mydomain.com/folder2/appl/custom/folder3 https://www.mydomain.com/log/folder3/folder2/name 到 现在,如果我将规则包括在web root.htaccess或个人.htaccess中,它

如何实现同时重写多个URL。我知道我可以一次重写一个url,但不确定如果多个url

假设我有这些文件并想重新写入它们:

https://www.mydomain.com/log/member/1

https://www.mydomain.com/folder2/appl/custom/folder3

https://www.mydomain.com/log/folder3/folder2/name

现在,如果我将规则包括在web root.htaccess或个人.htaccess中,它是如何工作的?格式是一样的吗

请让我知道

所有评论都非常感谢

更新

谢谢@ThinkingMonkey。代码运行良好。缺少了一点东西,那就是php处理程序,因为我使用index.php


缺少的行是:
DirectoryIndex.php
您的
文件夹
重写不是通用的。你必须有个人重写。与我之前的ans中提到的类似。您必须将它们添加到
webroot
.htaccess

RewriteEngine on
RewriteBase /

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !(?:\.\w+|/)$
RewriteRule (.*) /$1/ [R,L]

RewriteCond %{REQUEST_URI} ^(/log)(/\d+)$
RewriteRule ^ %1/member%2 [L]

RewriteCond %{REQUEST_URI} ^(/log)(/\w+)$
RewriteRule ^ %1/folder3/folder2%2 [L]

RewriteCond %{REQUEST_URI} ^(folder2)/(folder3)
RewriteRule ^ %1/appl/custom/%2 [L]

RewriteCond %{REQUEST_URI} ^(/folder2)
RewriteRule ^(.*)$ /accout/log/folder1/$1 [L]



RewriteCond %{REQUEST_URI} ^(/log)/member(/d+)$
RewriteRule ^ %1%2 [R,L]

RewriteCond %{REQUEST_URI} ^(/log)/folder3/folder2(/name)$
RewriteRule ^ %1%2 [R,L]

RewriteCond %{REQUEST_URI} ^(/folder2)/appl/custom(/folder3)
RewriteRule ^ %1%2 [R,L]

RewriteCond %{REQUEST_URI} ^/accout/log/folder1/folder2
RewriteRule accout/log/folder1/(folder2)(/(.*))?$ $1$2 [R,L]

谢谢你的思考。我会试试看,然后告诉你。我在另一篇文章中尝试了你的答案,但没有成功。知道为什么吗??它给网站带来了什么错误?我这样问是因为我在发布之前对其进行了测试。当我将代码放在web根目录的.htaccess中并尝试链接时,它们显示出来时没有wwwm,但只有https。看起来它不识别.php格式,而只识别html。@Digitalsite您为php文件设置了
AddHandler
?你还有什么重写规则?我不知道如何为php添加句柄。我还有一些其他规则,比如将主页重定向到https而不是http。另外一个规则是强制所有链接都有www。如果你想让我发布代码,我没有问题。谢谢
RewriteEngine on
RewriteBase /

RewriteCond %{ENV:REDIRECT_STATUS} 200
RewriteRule ^ - [L]

RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_URI} !(?:\.\w+|/)$
RewriteRule (.*) /$1/ [R,L]

RewriteCond %{REQUEST_URI} ^(/log)(/\d+)$
RewriteRule ^ %1/member%2 [L]

RewriteCond %{REQUEST_URI} ^(/log)(/\w+)$
RewriteRule ^ %1/folder3/folder2%2 [L]

RewriteCond %{REQUEST_URI} ^(folder2)/(folder3)
RewriteRule ^ %1/appl/custom/%2 [L]

RewriteCond %{REQUEST_URI} ^(/folder2)
RewriteRule ^(.*)$ /accout/log/folder1/$1 [L]



RewriteCond %{REQUEST_URI} ^(/log)/member(/d+)$
RewriteRule ^ %1%2 [R,L]

RewriteCond %{REQUEST_URI} ^(/log)/folder3/folder2(/name)$
RewriteRule ^ %1%2 [R,L]

RewriteCond %{REQUEST_URI} ^(/folder2)/appl/custom(/folder3)
RewriteRule ^ %1%2 [R,L]

RewriteCond %{REQUEST_URI} ^/accout/log/folder1/folder2
RewriteRule accout/log/folder1/(folder2)(/(.*))?$ $1$2 [R,L]