开发者

RewriteCond and RewriteRule newbie

I'm taking over a website for a client that is running on a custom built CMS (that I didn't write). I don't mess with .htaccess files usually because a lot of the hosting I do is on IIS, or I used WordPress as a CMS and don't have开发者_如何学Go to worry about messing with the .htaccess file. Here's the contents of the file:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteRule ^(.*)$ framework.php?%{QUERY_STRING}&resource=$1& [L]

I get what it's doing (sending all requests through the framework.php file). The client wants a WordPress blog added to their site. I'm placing it in a /blog/ folder. The problem is that because of the rewrite rules and conditions in the .htaccess file whenever I try to go /blog/ the other CMS freaks out because it doesn't like me trying to go there. My question is how do I write a rule/cond that tells apache to send all requests made to the /blog/ folder to the /blog/ folder, but keep all other requests piped through the framework.php file like it is now? Any help is appreciated, thanks!


You should be able to tell the main .htaccess file to ignore any /blog links by adding a RewriteCond to the main rule:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} !^/blog(/?)
RewriteRule ^(.*)$ framework.php?%{QUERY_STRING}&resource=$1& [L]

A /blog link won't be sent to framework.php, and should serve from the /blog directory normally. The Wordpress .htaccess file in that directory will be invoked as it normally would, and should be able to handle Wordpress links from there.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜