Forum Moderators: phranque
I have a root server, and many domains working from it.
In one of my domains, I am using Wordpress. For their "permalinks" they have this kind of htaccess code which I am supposed to put into the wordpress installation directory (which is /html/wordpress on my domain's public_html) --
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /html/wordpress/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /html/wordpress/index.php [L]
</IfModule>
I would like to take this into the main httpd.conf file, but when I put this above directive into the VirtualHost entry of this domain, I get this error:
yntax error on line 1464 of /usr/local/apache/conf/httpd.conf:
RewriteBase: only valid in per-directory config files
What is the best way to convert this into rewrite instructions for the main Apache config file? Sorry, I searched this forum but couldnt come up with a similar question. I did find out that "!-f" and the "!-d" in the code above mean that we should leave directories alone and just serve the files from an index file.
Appreciate any ideas or advice. Thanks!
RewriteCond %{DOCUMENT_ROOT}/html/wordpress%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}/html/wordpress%{REQUEST_URI} !-d
RewriteRule . /html/wordpress/index.php [L]
RewriteRule ^test-path-builder http://www.example.com/html/wordpress/index.php?tested-filepath=%{DOCUMENT_ROOT}/html/wordpress%{REQUEST_URI} [R=301,L]
You also don't need the <IfModule> container unless you want this code to fail silently on servers without mod_rewrite installed.
Jim
One problem. I want this condition to take over ONLY when "/html/wordpress" is in the URI. But right now, while this was working, the rule somehow took over "/html" as well!
Is there any way to make sure that "/html/" remains what it is, and the only time the above rule takes over is when there is "/html/support" in the URI?
For example:
RewriteRule ^/html/[b](^[(wordpress)]*)[/b]$ /html/$1 [L]
RewriteCond %{DOCUMENT_ROOT}/html/wordpress%{REQUEST_URI} !-f
RewriteCond %{DOCUMENT_ROOT}/html/wordpress%{REQUEST_URI} !-d
RewriteRule . /html/wordpress/index.php [L]
The item in bold is what I don't know how to write. How should I check for any word "other than wordpress"? Would this work anyway?