开发者

Rewrite only specific URL's through .htaccess

开发者 https://www.devze.com 2023-01-20 18:05 出处:网络
I have created a front controller for my website. I want to pass all requests to the website through this front controller. Now I also have some other software installed in the web root and right now

I have created a front controller for my website. I want to pass all requests to the website through this front controller. Now I also have some other software installed in the web root and right now I am adding those folders to ignore via .htaccess so that their requests also don't go to front controller. I am doing something like below,


  RewriteEngine On
  RewriteCond $1 !^(folder1|folder2|folder3|robots\.txt)
  RewriteRule ^(.*)$ index.php [QSA,L]

This works for now, but is there a way to add requests only for specific domain or folder t开发者_开发百科o get passed through index.php for Eg: www.mysite.com or www.mysite.com/folder4 or mysite.com.

This way I don't have to keep adding folders to ignore whenever a new one is created.

Thanks.

EDIT: I'll try and make it simpler. I want all the requests for one specific folder and main site to go through a front controller. Other than these, all requests should be processed as usual


You could use these conditions instead to exclude any request that can be mapped onto existing files or directories:

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d


You can use the SERVER_NAME variable:

RewriteCond %{SERVER_NAME} ! ^(www\.)?mysite\.com$
0

精彩评论

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