Google sitemap

Using mod_rewrite to handle various content issues

Google sitemap

Postby mmo » Sun Nov 12, 2006 3:42 am

Does anyone know how to make this directive (currently in .htaccess) work in Apache's configuration file (httpd.conf)?
Code: Select all
RewriteEngine On
RewriteRule ^sitemap.xml$ /sitemap.php [L]

Simply copying both lines to httpd.conf doesn't seem to work.
I prefer to use this method as opposed to parsing all XML files.
mmo
 
Posts: 5
Joined: Sun Nov 12, 2006 3:31 am
Location: the Netherlands

Postby richardk » Sun Nov 12, 2006 5:47 am

In the <Directory> block for your document root with:
Code: Select all
^/sitemap.xml$
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby mmo » Sun Nov 12, 2006 9:56 am

I am not really shure what is considered the document root, but I have tried both these configurations and they don't work either:

Code: Select all
<Directory "/var/www/html">
    Options -Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    RewriteEngine On
    RewriteRule ^/sitemap.xml$ /sitemap.php [L]
</Directory>

And also:
Code: Select all
<Directory ~ ".*/public_html">
    RewriteEngine On
    RewriteRule ^/sitemap.xml$ /sitemap.php [L]
</Directory>


I really appreciate any help, thanks!
mmo
 
Posts: 5
Joined: Sun Nov 12, 2006 3:31 am
Location: the Netherlands

Postby richardk » Sun Nov 12, 2006 10:16 am

Your document root is the directory you put you are putting the sitemap.php file in.

Have you actually go multiple document roots?

Maybe you want:
Code: Select all
<Directory "/*/public_html">
    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^/sitemap.xml$ /sitemap.php [L]
</Directory>


Or
Code: Select all
<Directory "/*html">
    Options +FollowSymLinks
    RewriteEngine On
    RewriteRule ^/sitemap.xml$ /sitemap.php [L]
</Directory>
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Still not working

Postby mmo » Mon Nov 13, 2006 2:04 am

I tried your suggestions, but it's still not working. I use a VirtualHost directive to host multiple sites on this server.
I now have these lines in the configuration file:
Code: Select all
<Directory ~ ".*/public_html">
    RedirectMatch (.*)login/?$  $1login.php
    RewriteEngine On
    RewriteRule ^/sitemap.xml$ /sitemap.php [L]
</Directory>

For some strange reason the RedirectMatch is working but the RewriteRule is not.

Thanks again for your help!
mmo
 
Posts: 5
Joined: Sun Nov 12, 2006 3:31 am
Location: the Netherlands

Postby richardk » Mon Nov 13, 2006 1:45 pm

Try adding:
Code: Select all
Options +FollowSymLinks

to the <Directory> or the <VirtualHost>.
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Postby mmo » Tue Nov 14, 2006 2:50 am

Hi Richard, thanks for your time and patience.
Unfortunetaly, it's still not working and I have absolutely no clue why, I have now tried every imaginable combination of settings.
Maybe you could have a look at the file and see if anything is wrong:
Code: Select all
(Code removed because irrelevant in retrospect)
Last edited by mmo on Wed Nov 15, 2006 5:16 am, edited 1 time in total.
mmo
 
Posts: 5
Joined: Sun Nov 12, 2006 3:31 am
Location: the Netherlands

Postby richardk » Tue Nov 14, 2006 8:15 am

Try putting the <Directory> last. Else replace the mod_rewrite with:
Code: Select all
Redirect 301 /sitemap.xml /sitemap.php
richardk
 
Posts: 8800
Joined: Wed Dec 21, 2005 7:50 am

Found it!

Postby mmo » Wed Nov 15, 2006 5:14 am

After inspecting the mod_rewrite log files I have found the solution:
Code: Select all
<Directory ~ ".*/public_html">
    RewriteEngine On
    RewriteRule (.*)sitemap.xml$  $1sitemap.php [L]
</Directory>

Thanks again, Richard, for your suggestions, they kept me from giving up right away.
mmo
 
Posts: 5
Joined: Sun Nov 12, 2006 3:31 am
Location: the Netherlands


Return to Content

Who is online

Users browsing this forum: No registered users and 17 guests

cron