繁体   English   中英

htaccess中的wordpress自定义重写规则

[英]wordpress custom Rewrite rule in htaccess

在我的options-permalink.php中,我有一个自定义结构,例如http://myexamplesite.com/%category%/%postname%.html

我的.htaccess:

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

</IfModule>

所以问题是:我需要在某些指定的帖子前使用RewriteRule。 例如,如果我在浏览器http://myexamplesite.com/spec1.html中键入,我必须看到URL http://myexamplesite.com/category1/mycustompost.html,而无需重定向到此页面。

为什么我的RewriteRule显示404错误?

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

RewriteRule ^spec1.html /category1/mycustompost.html [L,QSA]
RewriteRule ^spec2.html /category2/mycustompost2.html [L,QSA]

</IfModule>

感谢您的回答!

您可以尝试使用此语法。

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]

RewriteRule ^spec1.html /category1/mycustompost.html [L,QSA]
RewriteRule ^spec2.html /category2/mycustompost2.html [L,QSA]

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