URL重定向和重写同时进行

时间:2017-03-06 22:23:54

标签: wordpress apache url-rewriting url-redirection

我在亚马逊EC2上托管了sajjanlamichhane.com网站。但我的实际网站是sajjanlamichhane.com/wp/。所以,我重定向URL,但我想掩盖重定向URL。我该怎么做呢? 我在下面有这个

Listen 80
<VirtualHost *:80>
ServerAdmin root@sajjanlamichhane.com
ServerName sajjanlamichhane.com
ServerAlias www.sajjanlamichhane.com
DocumentRoot /var/www/sajjanlamichhane.com/
ErrorLog /var/www/sajjanlamichhane.com/logs/error.log 
CustomLog /var/www/sajjanlamichhane.com/logs/access.log combined
Redirect http://sajjanlamichhane.com "http://sajjanlamichhane.com/wp/
RewriteEngine on
RewriteRule ^/$ http://sajjanlamichhane.com/wp/index.php [R=301,NC,L]
# remove www
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [NE,R=301,L]
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$
RewriteRule !^wp/ /wp%http://sajjanlamichhane.com [L]
</VirtualHost>

1 个答案:

答案 0 :(得分:2)

这就是你解决的问题。更多链接阅读: http://www.willmaster.com/library/web-development/url-masking.php

    Listen 80

<VirtualHost *:80> 

     ServerAdmin root@sajjanlamichhane.com
     ServerName sajjanlamichhane.com
     ServerAlias www.sajjanlamichhane.com
     DocumentRoot /var/www/sajjanlamichhane.com/
     ErrorLog /var/www/sajjanlamichhane.com/logs/error.log 
     CustomLog /var/www/sajjanlamichhane.com/logs/access.log combined
     Redirect http://sajjanlamichhane.com "http://sajjanlamichhane.com/wp/
     RewriteEngine on
     RewriteCond http://sajjanlamichhane.com/wp/index.php http://sajjanlamichhane.com/wp/index.php$
     RewriteRule .* /wp/index.php [L]



</VirtualHost>