如何通过htaccess

时间:2018-06-12 11:41:52

标签: apache .htaccess url mod-rewrite

我对make .htacces进行模式重写时遇到了一些问题。

当我进入:

时,我需要设置
example.com/ address bar should show www.example.com/ 
and load site from ./www/site

(www.)example.com/site/ address bar should show www.example.com/  
and load site from ./www/site

(www.)example.com/wordpress/ address bar should show www.example.com/blog/  
and load site from ./www/wordpress

(www.)example.com/blog/ address bar should show www.example.com/blog/  
and load site from ./www/wordpress

在服务器端是

example.com and www.example.com bind ./www

./www/site
./www/wordpress

./www/blog is not exist.

我还要重定向网址:

(www.)example.com/site/ to (www).example.com/

我的托管是OVH:http://pro.ovh.net/infos/ 我把.htaccess放到dir ./www/(正确的地方?)。

请告诉我需要创建哪些rewerite规则。

我的.htaccess文件:

RewriteEngine on

#blog load form .\www\wordpress
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /blog/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^blog/?$ wordpress/index.php [L,NC]

#cover worpress - problem
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com [NC] 
RewriteRule ^wordpress/?$ http://www.example.com/blog/$1 [L,P,NC] 

#cover site - problem
RewriteCond %{HTTP_HOST} ^(www\.)?example\.com [NC] 
RewriteRule ^site/?$ http://www.example.com/$1 [L,P,NC] 


#load site from .\www\site
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/site/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /site/$1
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteRule ^(/)?$ site/index.php [L,NC]

0 个答案:

没有答案