简体   繁体   English

在wordpress中输入自己的.htaccess重写规则

[英]Enter own .htaccess rewrite rules in wordpress

I want to write a own rewrite rule into my htacces. 我想将自己的重写规则写入htacces。 The redirection itself works fine but Wordpress validates the URI with $_SERVER["REQUIRE_URI"] . 重定向本身可以正常工作,但是Wordpress使用$_SERVER["REQUIRE_URI"]验证URI。 So the site Title is Changed automatically to page not found, the loop doesn't works and so on. 因此,网站标题自动更改为找不到页面,循环不起作用,依此类推。

Is there anyway to do this? 反正有这样做吗?

If not is there a other possibility actually I only need a really simple redirect from "www.example.com/test/" to "www.example.com/t.php?a=1 " So it's completely static i don't need patterns at all. 如果没有,实际上我只需要一个非常简单的重定向即可从"www.example.com/test/"重定向到"www.example.com/t.php?a=1 ”,因此它完全是静态的,我不需要根本需要模式。 I have already tried it with "frameset" but that looks pretty ugly and makes the process slow. 我已经使用“ frameset”进行了尝试,但是看起来很丑,并且使过程缓慢。

Thank you very much 非常感谢你

Jakob 雅各布

My .htaccess file: 我的.htaccess文件:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# My Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^Malta/$ http://www.reisekontrast.de/Index?malta=1  [QSA,L]
RewriteRule ^China/$ http://www.reisekontrast.de/Index?china=1  [QSA,L]


# WP Rules
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

# END WordPress

We need your original .htaccess file. 我们需要您的原始.htaccess文件。 This is an easy rewrite (redirect), but wordpress already has URL Rewriting rules. 这很容易重写(重定向),但是wordpress已经具有URL重写规则。 To help you best would mean we need to work cohesively with what settings you already have running. 为了给您最好的帮助,这意味着我们需要与已经运行的设置紧密结合。 Otherwise your are just going to break Wordpress but get your URL's working. 否则,您将破坏Wordpress,但可以使用URL。

Also, as a primer question, does your server support full override in htaccess? 另外,作为入门问题,您的服务器是否支持htaccess中的完全覆盖?

Based on your HTACCESS file, I would add the section for "Custom" Rules. 根据您的HTACCESS文件,我将添加“自定义”规则的部分。 That way it bypasses the Rewrite Conditions that are arbitrary in this type of rewrite. 这样,它绕过了这种重写类型中任意的重写条件。

Hope this helps! 希望这可以帮助! Let me know if I can provide more detail or other options. 让我知道是否可以提供更多详细信息或其他选择。

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /

# Custom rules
RewriteRule /test/(.*) http://example.com/t.php?a=1 [NC]

# My Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^Malta/$ http://www.reisekontrast.de/Index?malta=1  [QSA,L]
RewriteRule ^China/$ http://www.reisekontrast.de/Index?china=1  [QSA,L]


# WP Rules
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

</IfModule>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM