0

httpd.conf または vhosts.conf を編集するためのアクセスを許可しない新しいホストに移動するので、代わりに .htaccess を使用する必要があります。

これが私の既存の仮想ホストconfです:

<VirtualHost *:80>
    ServerName example.com
    ServerAlias www.example.dev

    DocumentRoot /path/to/html       
    Alias /sitemap.xml /path/to/html/sitemap.php
    Alias /sitemap.xml.gz /path/to/html/sitemap.php
    AliasMatch ^/sitemap(.*).xml /path/to/html/sitemap.php
    AliasMatch ^/sitemap(.*).xml.gz /path/to/html/sitemap.php
    Alias /robots.txt /path/to/html/robots.php
    AliasMatch ^/robots.txt /path/to/html/robots.php

    <Directory /path/to/html>
        AllowOverride none
        Options all
        Order allow,deny
        Allow from all
        Deny from none

        <IfModule mod_rewrite.c>
            Options +FollowSymLinks -MultiViews
            RewriteEngine On
            # The following redirects all directories to root using PATH variables
            # Ex. /abc/def/ redirects to /index.php/abc/def/
            RewriteCond %{REQUEST_URI} !=/server-status
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule (.*) index.php/$1 [L]
        </IfModule>
    </Directory>
</VirtualHost>

目標は、htaccess を使用して同じ対話を取得することです。

私が探している主な相互作用は次のとおりです。

sitemap.xml => sitemap.php
sitemap-abc.xml => sitemap.php
sitemap-___.xml => sitemap.php
sitemap-xyz.xml => sitemap.php
robots.txt => robots.php

/abc/def/ => /index.php/abc/def/

上記の vhosts.conf は私の古いホストでは問題なく動作しますが、htaccess のみを使用して新しいホストでこれを実行する方法がわかりません。

4

1 に答える 1

0

私の特定の問題は、mod_rewrite の問題ではなく、ホスティング構成にあったことがわかりました。しかし、他の人にとっては、ここに私の解決策があります:

/path/to/html/.htaccess

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
于 2013-07-09T21:05:47.190 に答える