I have this in my .htaccess - works great for permalinks, instead of what WP puts in it:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ /index.php/$1
Now, I have put a file, named test.php, in my theme-dir. How do I get to see that page in the browser? No matter what I try, I get the standard WP frontpage, which is why I suspect a problem with .htaccess. But how do I make a call to http://blog.rander.dk/test.php display the file? I tried with
RewriteCond %{REQUEST_FILENAME} test.php
RewriteRule ^/$ http://blog.rander.dk/wp-content/themes/peachy/test.php
before the above lines, but it does absolutely nothing...
Any ideas?
What's wrong with WordPress' default rules? They work great for me.
What is wrong with them is, that if I make .htaccess writable and let WP write the rules, noone can access anything in my blog - they get a 403 Forbidden...
IsaacSchlueter
Member
Posted 4 years ago #
Let's say that your theme dir is /wp-content/themes/peachy/. Add a rule like this:
RewriteCond /wp-content/themes/peachy/%{REQUESTFILENAME} -f [NC]
RewriteRule ^(.*)$ /wp-content/themes/peachy/$1 [L]
The rule that you had won't work because the request doesn't match ^/$. If you changed that part to be ^.*$, then it'd work.
Say what?
The new mod_rewrite rules you used, which by the way will be the default in the new WordPress 1.6, should actually do the following for each request:
# Is the IRI a real file?
# If yes, then exit from the rewrite engine
RewriteCond %{REQUEST_FILENAME} !-f
# Is it the IRI a real directory?
# If yes, then exit from the rewrite engine
RewriteCond %{REQUEST_FILENAME} !-d
# Else prefix the request IRI with to /index.php (so WordPress will handle it internally, PHP-wise)
RewriteRule ^(.+)$ /index.php/$1
So there shouldn’t be any problems.
Mathias, thanks for the run-down. Although it didn't solve my problem the way I expected it to, it did set me off in a new direction...
So, I have now placed my file in WPs root, and put include ("$_SERVER[DOCUMENT_ROOT]/wp-blog-header.php"); in the first line of my code (as I ofcourse needed the theme-layout and sidebar) - and NOW it works like it should!
And before anyone asks: The reason I put it in the root is, that the above included file in itself includes some other files, which would fail if I did not put it in the WP-root...