开发者

Error with htaccess rewrite

开发者 https://www.devze.com 2023-01-17 12:48 出处:网络
I have a problem with two htaccess files that i have in a hosting at godaddy. I have multiple domains in the same hosting and therefore i usen htaccess which i found and which is working great:

I have a problem with two htaccess files that i have in a hosting at godaddy. I have multiple domains in the same hosting and therefore i usen htaccess which i found and which is working great:

RewriteEngine On
RewriteBase /

# To redirect www.site1.com to /site1/
RewriteCond %{REQ开发者_运维知识库UEST_URI} !^/site1/
RewriteCond %{HTTP_HOST} ^(www\.)?site1\.www\.
RewriteRule ^(.*)$ site1/$1 [L]

This is great because it redirects whoever goes to site1.com to /site1/ and i have the page for site1 in that directory. In fact i have this same three others domains and they work great (the folder is hidden in the url bar).

My problem is that i added a new domain (site2.com) which is Zend app. Therefore it has it's own htaccess for rewriting the url (for passing parameters in a nicer way in the url). For this one it doesnt works. In fact i am redirected BACK to / and i get a page /index.html which nobody is supposed to be able to get. Just to notice: the zend app's webroot is 'www':

The second htacess, inside /site2/www is

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

I don't know how is it going back. Aren't htaccess commands path relative ? why is it going back two levels (remember that it is in /site2/www and the file i'm getting is at /index.php (a test))


it is not relative it respect you RewriteBase from upper level where is / ... Just put in htaccess under site2

RewriteBase /site2/
0

精彩评论

暂无评论...
验证码 换一张
取 消