Html 使用htaccess重写URL

Html 使用htaccess重写URL,html,wordpress,.htaccess,Html,Wordpress,.htaccess,我正在尝试将url重写到我的wordpress主题文件夹,如下所示: 实际URL:http://www.mydomain.com/wp-content/themes/mytheme/style.css 正在尝试重写到:http://www.mydomain.com/mytheme/style.css 以下是我的.htaccess文件中的内容,该文件位于我的主文件夹中,但不起作用: RewriteEngine On RewriteRule ^mytheme/(.*) /wp-content/the

我正在尝试将url重写到我的wordpress主题文件夹,如下所示:

实际URL:
http://www.mydomain.com/wp-content/themes/mytheme/style.css

正在尝试重写到:
http://www.mydomain.com/mytheme/style.css

以下是我的.htaccess文件中的内容,该文件位于我的主文件夹中,但不起作用:

RewriteEngine On
RewriteRule ^mytheme/(.*) /wp-content/themes/mytheme/$1 [QSA,L]

我做错了什么?

这是您的.htaccess文件中唯一的一行吗

您需要在该行上方启用“重写引擎”(RewriteEngine),以使“重写规则”(RewriteRules)正常工作。

#开始WordPress
#Begin WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^mytheme/(.*) /wp-content/themes/mytheme/$1 [QSA,L]
RewriteRule ^plugins/(.*) /wp-content/plugins/$1 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
#End WordPress
重新启动发动机 重写基/ 重写规则^index\.php$-[L] 重写规则^mytheme/(.*)/wp content/themes/mytheme/$1[QSA,L] 重写规则^plugins/(.*)/wp content/plugins/$1[QSA,L] 重写cond%{REQUEST_FILENAME}-F 重写cond%{REQUEST_FILENAME}-D 重写规则/index.php[L] #结束WordPress
这就是htaccess的外观

但是你需要告诉wordpress使用新的URL

我建议您查看此github回购


特别是文件重写和相关URL。

对不起,我也有。以上更新。谢谢,太好了。非常感谢。