# how can i enable mod_rewrite for Documentroot

## xsteadfastx

i just played around a bit with apache and wordpress. i thought mod_rewrite is working already. its compiled and it even gets loaded in the http.conf

```
LoadModule rewrite_module                modules/mod_rewrite.so
```

but im sure this is some kind of trick howto enable it. i read alot about having a .htaccess but isnt there a other way to write it in the directory settings for the server? already thank you all alot for any tip  :Smile: 

----------

## xsteadfastx

if someone just has a url or something for me..i would be really happy

----------

## tuxmin

http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

----------

## xsteadfastx

 *tuxmin wrote:*   

> http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

 

thats what i found too...but an example would be wonderful. i think its pretty complicated

----------

## tuxmin

Well,

what do you want to rewrite? You may have noticed that mod_rewrite is

```

 the Swiss Army Knife of URL manipulation!

```

There isn't such thing as *the* rewrite rule... please be more specific...

Alex!!!

----------

## xsteadfastx

 *tuxmin wrote:*   

> Well,
> 
> what do you want to rewrite? You may have noticed that mod_rewrite is
> 
> ```
> ...

 

hey alex thank you already  :Smile: 

i want to get it working with wordpress. thats all i know..i checked the webpage but they just always talk about a .htaccess file

----------

## tuxmin

Hmmm,

insufficient data ;P... can you point me to the document?

----------

## tuxmin

Googling around I found the doc you  are referring to. So I guess wordpress simply updates .htaccess itself. The only thing you have to do is to enable rewriting globally:

```

Description: Enables or disables runtime rewriting engine

  Syntax: RewriteEngine on|off

  Default: RewriteEngine off

  Context: server config, virtual host, directory, .htaccess

  Override: FileInfo

  Status: Extension

  Module: mod_rewrite

```

So put 

```

RewriteEngine On

```

in either main config, virtual host, or directory context. I guess you shouldn't put it in .htaccess as wordpress overwrites it.

----------

## xsteadfastx

thank you alot. i just need to learn alot more about apache. i saw i easily can put the rewrite option on in my .htaccess ( when i create one) and i need to get sure AllowOveride is not set None for that directory...thank you alot

----------

## xsteadfastx

i just found out...when i enabled the AllowOverride and do a touch .htaccess in the wordpress directory....it even sets it for me  :Smile:  yay

----------

## tuxmin

nice, nice  :Smile: 

For security reasons you should only

```

AllowOverride FileInfo

```

not "All".

----------

## xsteadfastx

 *tuxmin wrote:*   

> nice, nice 
> 
> For security reasons you should only
> 
> ```
> ...

 

where is the difference? but thank you so much for all your help

----------

## tuxmin

The AllowOverride directive can have a number of parameters. Each one defines a subset of directives that can be used in .htacces files and which override more global settings in your httpd.conf.

Now if you define "all" as a parameter all these derectives are allowed, especially the AuthConfig directives.

It's normally a bad idea allowing the apache process write access to the DocumentRoot, especially .htaccess files. An attacker could probably gain write access with the rights of the apache user, thus being able to modify .htaccess files.

As a rule of thumb: Keep your configuration as tight as possible to minimise risks of being hacked.

hth, Alex!!!

----------

## HeXiLeD

i am having a problem using mod_rewrite

all i want to do is simple.

someone hits port 80 and they are sent to port 443

the module is loaded and set in the apache conf.

but i seem not to be able to make it  work for some reason and i am having a few doubts.

where should i insert these lines ? in httpd.conf  or in the virtual host ? or both ?

i have tried them all but mabe i am skiping something.

```
RewriteCond     %{SERVER_PORT}  !^443$

RewriteRule     ^/(.*)          https://%{my.ip}/$1 [NC,R,L]
```

at the same time i am wondering if im am setting yup this properly.

I have read googled for this and the example  that i am using seems to be ok.

I am lost.

Any help  is very welcome.

Server version: Apache/2.0.55

Server built:   Jan 19 2006 14:09:05

Thank you

----------

## tuxmin

Perhaps not what you are looking for, but it works  :Smile: 

https://forums.gentoo.org/viewtopic-t-201995-highlight-apache.html

Greetz, Alex!!!

----------

