views:

59

answers:

2

hey guys, i have an really unusual problem i've never had before. i've no .htaccess file on my server. looked everywhere, there is just no file, but a Wordpress Plugin (AskApacheRewriteRules) tells me that the following Rules are active:

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

any idea why that could be, i've already wrote my hosting provider, but their service isn't the best.

even if i create an htaccess file with other rules and save it to my root of the server, it doesn't change anything. The plugin always tells me the same and i believe the plugin, because i'm having issues with the /index.php/ in my url (that i don't want to have).

any ideas?

A: 

Have you checked if it's defined in your apache configuration file (it appears that the plug is showing an excerpt from that).

normman
where can i find that file? i had a file ".viminfo" and ".listing" up there, i deleted both of them :) … i can't figure out why I can't activate permalinks without /index.php" in it. i done a lot of wordpress setups and it always worked. this time it simply bugs me.
+1  A: 

On the AskApacheRewriteRules options page, did you make sure that using_index_permalinks is set to false and that using_mod_rewrite_permalinks is set to true? If this isn't the case, WordPress will attempt to use PATH_INFO for your permalinks, resulting in /index.php/(permalink_structure).

Note that the WordPress rewrite class stores its rewrite rules as a WordPress option in the database, which is where AskApacheRewriteRules gets its information. The plugin also apparently formats the rules with the mod_rewrite_rules function before echoing them to the page, which will surround them with:

<IfModule mod_rewrite.c>
...
</IfModule>

So, the likely reason you can't find the .htaccess file is because it doesn't exist; the rules are just present in the database. The reason why the rules are present in the database is because you're using permalinks, and this is the auto-generated WordPress ruleset, which is saved regardless of whether it's actually being used or not.

Edit: You must have a .htaccess file in the root of your web directory with the following contents:

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

<IfModule !mod_rewrite.c>
    # If mod_rewrite isn't available, we'll do this a hackish (and bad) way...
    ErrorDocument 404 /index.php
</IfModule>

The rewrite_rules option is stored at SELECT option_value FROM wp_options WHERE option_name = 'rewrite_rules', but it gets regenerated every time you change the permalink, and isn't used except for writing to .htaccess from what I can tell.

Anyway, those are definitely the correct rules for what you want to do. Are you sure that mod_rewrite is enabled on your host?

Edit:

Let's make 100% sure that mod_rewrite is working correctly and go from there.

Create a .htaccess file in your web root with the following rules, exactly as written:

RewriteEngine On
RewriteRule ^rwtest http://stackoverflow.com/ [R,L]

Then go to your site with the URL example.com/rwtest and see if you get redirected to StackOverflow. If not, something is wrong with mod_rewrite. If you do, then at least we know that piece isn't the problem.

Tim Stone
using_index_permalinks is set to false and using_mod_rewrite_permalinks is set to true! I've set the permalinks they way i want them to be: /%postname/ … and nothing works anymore. any link to a article or page i click ends in an 404. if i add index.php/%postname/ it works again. no .htaccess file present and AskApacheRewriteRules still prints the same. Exactly that's my problem. Maybe i simply need to find the entry in the database and edit it. I think the following line shouldn't be in there in order to work: RewriteRule ^index\.php$ - [L] Any Idea where I can find this options in the db?
If there isn't a `.htaccess` file and `using_mod_rewrite_permalinks` is set to `true` (and there's not an `ErrorDocument` hack) though, you *should* get 404 errors. Did you try removing the `index.php` from the permalink format and copying those rules to a file named `.htaccess` in your site route? As for the DB option, I'm not sure exactly where that is, I'll check the code in a bit.
Tim Stone
If there isn't a .htaccess file and using_mod_rewrite_permalinks is set to true (and there's not an ErrorDocument hack) though, you should get 404 errors. -> that's exactly the case! that's what I'm talking about. i'm getting 404's if it's turned on. However I WANT TO TURN THEM ON. i don't wanna have an index.php inside of my url. … but i can't do anything about it. if I copy an htaccess file over to the root of the server it doesn't do anything different. it just seems, wordpress is always using the htaccess that the plug tells me. And that's of course the wrong one.
Eh...See my edit.
Tim Stone
my provider assured that mod_rewrite is enabled. maybe i do get something wrong with mod_rewrite: if i set the permalinks the way i want them (/%postname%/) i get only 404's. If i try manually adding a index.php between my hostname and the postname the site always redirects to the permalink structure i want to have. so in this case it doesn't matter if i enter dom.com/about or dom.com/index.php/about - both end in 404's. if I set the permlinks back to /index.php/%postname%/ everything works fine. if i delete the index.php manually from the url i get a 404 again. htaccess file lies on server.
Alright. Please test `mod_rewrite` using the instructions I've provided in the edit, just so we can eliminate the possibility of some conflict with the configuration. Once you do that, we'll go from there.
Tim Stone
i'll tet an 404! freaking provider. i'll call them immedietely. thank you for your help so far. we'll propably come back to you. ;)