0

私のApachehtaccessファイルには、すべてのwwwURLをwordpressの非wwwURLにリダイレクトするために使用される次のコードがあります。これは、ルートを除くすべてのURLで機能します。

たとえば、http: //www.noshon.it/recipesは適切にhttp://noshon.it/recipesにリダイレクトします。ただし、http: //www.noshon.itは誤ってhttp://noshon.it/wordpress(404ページを受信する)にリダイレクトします。

ルートを除いてすべてのULRが機能する理由がわかりません。どんな助けでも大歓迎です。

RewriteEngine On   
RewriteCond %{HTTP_HOST} ^www\.noshon\.it$ [NC]  
RewriteRule ^(.*)$ http://noshon.it/$1 [R=301,L]  
RewriteBase /  
RewriteRule ^index\.php$ - [L]  
RewriteCond %{REQUEST_FILENAME} !-f  
RewriteCond %{REQUEST_FILENAME} !-d  
RewriteRule . /index.php [L]  
4

1 に答える 1

0

リダイレクトが別のファイルで発生していたことを示唆してくれた @WebChemist に感謝します。Bitnami EC2 インスタンスの /opt/bitnami/apps/wordpress/conf/ ディレクトリに wordpress.conf という名前のファイルを見つけました。このファイルには次のコードが含まれていました。

# App url moved to root
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
#Alias /wordpress/ "/opt/bitnami/apps/wordpress/htdocs/"
#Alias /wordpress "/opt/bitnami/apps/wordpress/htdocs"

<Directory "/opt/bitnami/apps/wordpress/htdocs">
    Options Indexes MultiViews +FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    RewriteEngine On
    #RewriteBase /wordpress/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
<//Directory>

# Uncomment the following lines to see your application in the root
# of your URL. This is not compatible with more than one application.
RewriteEngine On
RewriteRule ^/$ /wordpress/ [PT]

書き換えは、このファイルの最後の行で発生していました。

RewriteRule ^/$ /wordpress/ [PT]  

このファイルを次のように変更したところ、リダイレクトが機能するようになりました。

# App url moved to root
DocumentRoot "/opt/bitnami/apps/wordpress/htdocs"
#Alias /wordpress/ "/opt/bitnami/apps/wordpress/htdocs/"
#Alias /wordpress "/opt/bitnami/apps/wordpress/htdocs"

<Directory "/opt/bitnami/apps/wordpress/htdocs">
    Options Indexes MultiViews +FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    RewriteEngine On
    #RewriteBase /wordpress/
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . index.php [L]
<//Directory>

# Uncomment the following lines to see your application in the root
# of your URL. This is not compatible with more than one application.
#RewriteEngine On
#RewriteRule ^/$ /wordpress/ [PT]
于 2012-09-18T14:26:13.057 に答える