2013-10-28 63 views
0

我想URL重寫我的wordpress主題的文件夾中,以便重寫URL:與htaccess的

實際URL:http://www.mydomain.com/wp-content/themes/mytheme/style.css

試圖改寫爲:http://www.mydomain.com/mytheme/style.css

這是我在我的.htaccess文件在我的home文件夾中,並且不工作:

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

我在做什麼錯?

回答

1
#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使用新的Url。

我建議你看看這個GitHub庫Roots Boilerplate->lib

特別是文件重寫和相對URL。

+1

太棒了。謝謝! – JROB

0

這是你在.htaccess文件中唯一的一行嗎?

爲了使RewriteRules正常工作,您需要在該行上方有RewriteEngine On

+0

對不起,我也有。上面更新。謝謝。 – JROB