【问题标题】:Rewriting URL with htaccess用 htaccess 重写 URL
【发布时间】:2013-11-06 16:51:06
【问题描述】:

我正在尝试将 url 重写为我的 wordpress 主题文件夹:

实际网址: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]

我做错了什么?

【问题讨论】:

    标签: html wordpress .htaccess


    【解决方案1】:

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

    您需要在该行上方添加 RewriteEngine On 才能使 RewriteRules 起作用。

    【讨论】:

    • 对不起,我也有。以上更新。谢谢。
    【解决方案2】:
    #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
    

    这就是你的 htaccess 的样子。

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

    我建议你查看这个 github repo Roots Boilerplate->lib

    尤其是文件重写和相对 url。

    【讨论】:

    • 太棒了。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-30
    • 2011-03-19
    • 2022-01-18
    • 2014-04-27
    • 2023-04-07
    • 1970-01-01
    相关资源
    最近更新 更多