htaccess到域重写器的文件夹不起作用

时间:2018-11-03 00:28:25

标签: regex apache .htaccess redirect mod-rewrite

我的.htaccess文件中有此代码

<IfModule mod_rewrite.c>
Options +FollowSymLinks -MultiViews
RewriteEngine On
RewriteBase /

RewriteRule ^ext(.*)$ https://newweb.site/parent/ext/$1 [R,L]
RewriteRule ^assets(.*)$ https://newweb.site/parent/assets$1 [R,L]
RewriteRule ^styles(.*)$ https://newweb.site/parent/styles$1 [R,L]
RewriteRule ^images(.*)$ https://newweb.site/parent/images$1 [R,L]

# The following 3 lines will rewrite URLs passed through the front controller to not require app.php in the actual URL. In other words, a controller is by default accessed at /app.php/my/controller, but can also be accessed at /my/controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ app.php [QSA,L]
</IfModule>

(最后一个是指phpBB) 鉴于我不知道.htaccess的工作原理,我尝试使用此代码将四个不同文件夹的所有元素重定向到外部域。 实际上,它应该是这样的:

oldwebsite.net/ext/file.js --> newwebsite.com/parentdir/ext/file.js
oldwebsite.net/assets/file.css --> newwebsite.com/parentdir/assets/file.css
oldwebsite.net/images/file.png --> newwebsite.com/parentdir/assets/file.png
...

这四个规则的问题在于,只有第一行不起作用,而其他行却相同。

您能告诉我解决问题的更有效方法吗? 非常感谢。

0 个答案:

没有答案