简体   繁体   English

涉及index.php的Wordpress重写规则不起作用

[英]Wordpress rewrite rule involving index.php doesn't work

Before I start, I'd like to say that I did search for topics similar to my problem and tried all solutions provided, but my problem still persists, so I had to post my own question. 在开始之前,我想说的是,我确实搜索了与我的问题类似的主题并尝试了提供的所有解决方案,但是我的问题仍然存在,因此我不得不发表自己的问题。

Anyway, inside our wordpress site, we have a page called site.com/shops and we want to put a parameter to it. 无论如何,在我们的wordpress网站内,我们有一个名为site.com/shops的页面,我们想为其添加一个参数。 After that we want to use a rewrite rule so that site.com/tx will load site.com/?pagename=shops&state=tx. 之后,我们要使用重写规则,以便site.com/tx将加载site.com/?pagename=shops&state=tx。 We put this on our .htaccess: 我们把它放在我们的.htaccess文件中:

RewriteRule ^tx(/)?$ index.php?pagename=shops&state=tx[L]

For some reason this doesn't work like we intended. 由于某些原因,它无法像我们预期的那样工作。 I checked to see if index.php was the problem by changing it to 我通过将它更改为来检查index.php是否是问题

RewriteRule ^tx(/)?$ test.php?pagename=shops&state=tx[L]

That worked, so I believe the problem is that it doesn't work if index.php was used. 那行得通,所以我相信问题是如果使用index.php则行不通。 How do I make it work using index.php? 如何使用index.php使其工作? TIA. TIA。

Replace .htaccess code with below code 用下面的代码替换.htaccess代码

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wordpress_test/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress_test/index.php [L]
</IfModule>

i hope it's works 我希望这是可行的

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

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