开发者

Need to use httpd.conf instead of .htaccess for rewrite

I am working on a host that blocks my .htaccess file from being used so I can not change my permalinks using it. I need to开发者_JAVA百科 figure out what code to use and where to put it in my httpd.conf file to get the same effect.

The code in the .htaccess file is below:

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


You'll need to wrap that code in a <Directory> directive. Where it goes will depend on what else you've got in your http.conf file. See the Apache docs for more info.

However, as blockhead says; if your host won't let you use .htaccess files, you've got virtually no chance of being allowed near the httpd.conf file.


For example, if you'd like to block access to GoogleBot throughout your entire server (which may be comprised of hundreds of virtual hosts), you can add this to your httpd.conf file:

#setup the root dir
<Directory />
    RewriteEngine On
    RewriteCond %{HTTP_USER_AGENT} Googlebot
    RewriteRule .* - [F,L]
</Directory>

This will send a HTTP 403 Forbidden to anyone who comes in with Googlebot in their user agent string. And this rewrite condition will be applied to ALL virtual hosts, by virtue of applying this to the "/" folder.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜