重写HTACCESS不重新定向的规则
我写了一个 RewriteRule 似乎不起作用。
该文件看起来像这样:
<IfModule mod_rewrite.c>
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(\/[parteneri]+)\/+([a-zA-Z\-\s]+)\/+([\/a-zA-Z\-\s]+)* index.php [L]
</IfModule>
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
我试图开始工作的行是这样的:
RewriteRule ^(\/[parteneri]+)\/+([a-zA-Z\-\s]+)\/+([\/a-zA-Z\-\s]+)* index.php [L]
正则表达式规则应该匹配以下格式的任何内容: /parteneri/event/
- 我确实知道正则表达式规则也匹配像这样的模式 /parteneri/events/asdf/adsf
,但这很好,因为我仍然希望将其重定向到索引页面。
我已经使用正则表达式检查器在线检查了正则表达式,并且模式似乎确实匹配。 .htaccess 文件位于 WordPress 网站上,我试图将包含 parteneri/post_type_name/
的每个链接重定向回索引页面。
编辑
我在另一个网站上有一个类似的 RewriteRule 可以工作,但只有这个也有参数。
RewriteRule ^([location]+)\/+([a-zA-Z\-\s]+)\/+([/a-zA-Z\-\s]+)*$ property-search.php?property-location=$2&sale-rent=$3 [L]
我缺少什么?
I have written a RewriteRule that doesn't seem to work.
The file looks like this:
<IfModule mod_rewrite.c>
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(\/[parteneri]+)\/+([a-zA-Z\-\s]+)\/+([\/a-zA-Z\-\s]+)* index.php [L]
</IfModule>
# BEGIN WordPress
# The directives (lines) between "BEGIN WordPress" and "END WordPress" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
# END WordPress
The line I am trying to get to work is this one:
RewriteRule ^(\/[parteneri]+)\/+([a-zA-Z\-\s]+)\/+([\/a-zA-Z\-\s]+)* index.php [L]
The Regex rule is supposed to match anything in the format: /parteneri/event/
- I do know that the regex rule matches patterns like this one as well /parteneri/events/asdf/adsf
, but that is fine as I would still like it to be redirected to the index page.
I have checked the regex online with a regex checker and the patterns do seem to match. The .htaccess file is on a wordpress website and I am trying to redirect every link that has parteneri/post_type_name/
back to the index page.
Edit
I have a similar RewriteRule on another website that works, only this one has parameters as well.
RewriteRule ^([location]+)\/+([a-zA-Z\-\s]+)\/+([/a-zA-Z\-\s]+)*$ property-search.php?property-location=$2&sale-rent=$3 [L]
What am I missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论