2013-07-29 5 views
0

У меня уже есть сайт www.example.com, который находится в/public_html/сайте.htaccess RewriteCond RewriteRule

Теперь я хочу указать www.example.com/anothersite/public_html/anothersite.

Как я могу?

.htaccess, в/public_html:

RewriteOptions inherit 

RewriteEngine on 
RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR] 
RewriteCond %{HTTP_HOST} ^www.example.com$ 
RewriteCond %{REQUEST_URI} !site/ 
RewriteRule (.*) /site/$1 [L] 

.htaccess, в/public_html/сайта:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /site/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /site/index.php [L] 
</IfModule> 

# END WordPress 

In The .htaccess в/public_html Я попробовал это, но это говорит об ошибке 404 Страница не найдена:

RewriteOptions inherit 

    RewriteEngine on 
    RewriteCond %{HTTP_HOST} ^example.com$ [NC,OR] 
    RewriteCond %{HTTP_HOST} ^www.example.com$ 
RewriteRule ^anothersite/(.*)$ http://example.com/anothersite/$1 [R=301,NC,L] 
RewriteCond %{REQUEST_URI} !site/ 
RewriteRule (.*) /site/$1 [L] 

Но я не знаю, почему он не работал в последний раз, но теперь он работает с Код выше ...

ответ

0

.htaccess, в/public_html:

Options +FollowSymLinks -MultiViews 
# Turn mod_rewrite on 
RewriteEngine On 

RewriteCond %{HTTP_HOST} ^(www.)?example\.com$ [NC] 
RewriteRule (?!^(?:site|anothersite)(?:/.*|)$)^.*$ /site%{REQUEST_URI} [L] 
+0

В HTAccess вы дали укажут оба example.com/site и example.com/anothersite в/public_html/сайта. Не так ли? – itsazzad

+0

Да над правилом пропустит '/ anothersite', и по умолчанию' http: // site.com/anothersite' будет загружать '/ anothersite' – anubhava

+0

Но его не работает. http://example.com/anothersite, указывающий на http://example.com/site также – itsazzad

Смежные вопросы